Favorite non-python language trick?

infidel saint.infidel at gmail.com
Fri Jun 24 10:51:52 EDT 2005


> def class Colour:
>     def __init__(self, blue=0, green=0, red=0):
>         # pseudo-Python code borrowing concept "with" from Pascal
>         with self:
>             blue = blue
>             green = green
>             red = red
>
> And now you can see why Python doesn't support this idiom.

Maybe it would make more sense if it was done a la Visual Basic

with self:
    .blue = blue
    .green = green
    .red = red

requiring a dot to be typed removes the ambiguity and gives the IDEs a
chance to Intellisense-ify your coding.




More information about the Python-list mailing list