[Python-3000] ugly pie: a "var" keyword

Georg Brandl g.brandl at gmx.net
Mon Oct 9 20:45:12 CEST 2006


Antoine Pitrou wrote:
> Le lundi 09 octobre 2006 à 12:49 +0200, Georg Brandl a écrit :
>> They wouldn't be "local" unless declared with "var", I assume.
> 
> Which is a sure way to cause all kind of frigging bugs if you forget to
> put "var", because then your variable is global, which is fine when it's
> a plain int or string, not when it's a complex object whose mere
> existence changes lots of things.
> 
> Javascript and Perl both suffer from this stupid design (Perl even
> invented "use strict" to circumvent it), please don't bring it to
> Python :-(

No contradiction from my side.

> (believe me, there are lots of reasons to hate Perl, but strange bugs
> that arise silently when you forgot "my" and thus retain some old value
> in a global variable is really one of the most horrible ones I
> encountered)
> 
> 
> Besides, in a well-written program, you will mostly access local
> variables (and attributes and methods), so let's make the clean common
> case easy to type and unobstrusive, and the rare dirty case easy to
> spot. Lots of "global" in a Python program immediately hint at dirty
> code.

Full ACK.

Georg



More information about the Python-3000 mailing list