On Jun 27, 9:48 am, Evan <[EMAIL PROTECTED]> wrote:
> HI,
>
> When I check example of "cmd2" module (a enhancement of cmd module), I
> can not understand all, for example: the  character "@",
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
> def options(option_list):
>      ..........<function content>........
>
> class cmd(...):
>     ...............................
>     @options([make_option('-p', '--piglatin', action="store_true",
> help="atinLay")])
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> I do not understand what "@options" does,   most time, I know what the
> meaning of character "*" and character "**", but I was not use "@"
> before.
>
> Thanks for your help.

The "@" sign is there to signify that what follows is a decorator.
They're kind of cool and kind of confusing. Basically they dynamically
alter a function, method or class and gives them additional
functionality. It's kind of like calling a function recursively. Check
out the following links:

http://www.python.org/dev/peps/pep-0318/
http://wiki.python.org/moin/PythonDecorators
http://www.ibm.com/developerworks/linux/library/l-cpdecor.html

Mike
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to