[Python-Dev] New Module: CommandLoop (original) (raw)
Raymond Hettinger raymond.hettinger at verizon.net
Mon Feb 20 02:03:15 CET 2006
- Previous message: [Python-Dev] New Module: CommandLoop
- Next message: [Python-Dev] New Module: CommandLoop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
@cmdloop.aliases('goodbye') @cmdloop.shorthelp('say goodbye') @cmdloop.usage('goodbye TARGET')
to just: @cmdloop.addspec(aliases=['goodbye'], shorthelp ='say goodbye', usage='goodbye TARGET') leaving the possibility of multiple decorators when one line gets to long: @cmdloop.addspec(aliases=['goodbye'], shorthelp ='say goodbye') @cmdloop.addspec(usage='goodbye TARGET # where TARGET is a filename in the current directory')
Well, why not support both, and leave it up to the user?
Having only one method keeps the API simple. Also, the addspec() approach allows the user to choose between single and multiple lines.
BTW, addspec() could be made completely general by supporting all possible keywords at once:
def addspec(**kwds): def decorator(func): func.dict.update(kwds) return func return decorator
With an open definition like that, users can specify new attributes with less effort.
Raymond
- Previous message: [Python-Dev] New Module: CommandLoop
- Next message: [Python-Dev] New Module: CommandLoop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]