[Python-Dev] More concerns about decorators (original) (raw)
Bob Ippolito bob at redivi.com
Mon Aug 16 06:52:43 CEST 2004
- Previous message: [Python-Dev] More concerns about decorators
- Next message: [Python-Dev] More concerns about decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Aug 16, 2004, at 12:41 AM, Roman Suzi wrote:
After playing with decorators alittle I found that @-syntax is nearly optimal especially that it comes before def, but there are other things to keep in mind. 1. Decorators must transfer doc-strings and probably even add information about functions 2. As now functions could have arbitrary attributes, some mechanism must be in place to ensure this information is not lost. If it is purely up to the decorator to decide, we will end up with undocumented functions...
def carryover(new, orig): if orig.doc: new.doc = orig.doc if orig.dict: d = dict(orig.dict) d.update(new.dict) new.dict = d return new
A built-in function like this would make it easy to preserve such information...
Is it possible to change function inplace? Is it even an option?
Not sure what you mean. Functions have a doc slot and a dict slot that are read/write. name is read-only. I have no idea if that answers your question or not (there are other slots, that is not a definitive list, but should cover all of the relevant ones).
-bob
- Previous message: [Python-Dev] More concerns about decorators
- Next message: [Python-Dev] More concerns about decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]