+= as declaration wish

Erik Max Francis max at alcyone.com
Fri Feb 16 03:46:58 CET 2001


"Gregory (Grisha) Trubetskoy" wrote:

> Am I missing something obvious when I think that it'd be nice if you
> could
> do:
> 
> x += 3
> 
> and if x didn't exist, += would simply act like = rather than raise an
> exception.

Avoiding such magic like this is what makes Python a well-designed
language.  If you want x to default to something, you can set it to that
yourself before you start using +=.  (Besides, what should it default to
for ints? strings? lists? user-defined types?)

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Love is the most subtle form of self-interest.
\__/ Holbrook Jackson
    Polly Wanna Cracka? / http://www.pollywannacracka.com/
 The Internet resource for interracial relationships.



More information about the Python-list mailing list