Extending Python Syntax with @
Edward K. Ream
edreamleo at charter.net
Wed Mar 10 18:02:27 EST 2004
> @x @y @z -- short for instance variables in a method definition
This is completely unnecessary. Leo uses the following convention:
def whatever(self):
v = self
v.whatever
The assignment v = self (or x = self etc.) indicates the expected type of
self and saves keystrokes. This convention has been useful in refactorings
when moving methods from one class to another: all that had to be done is to
change the v = self line to something else.
BTW, it would also be possible to define the function as follows:
def whatever(v):
v.whatever
However, this isn't proper Python style and Pychecker complains.
Edward
--------------------------------------------------------------------
Edward K. Ream email: edreamleo at charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
More information about the Python-list
mailing list