declaration of variables?

Bengt Richter bokr at oz.net
Sun Feb 16 18:56:18 EST 2003


On Sun, 16 Feb 2003 20:24:21 +0100, =?ISO-8859-1?Q?Andr=E9_Jonsson?= <tatsujin at spamgoeshere.despammed.om> wrote:

>Alex Martelli wrote:
>>>:-)  I mostly meant that Python seems more "aware" than most other
>>>:languages of
>>>usability and readability. Do those not count?
>> 
>> Of course; they're the main reasons Python avoids declarations.
>
>Dare I quote the Python Zen? "Explicit is better than implicit". I concurr, declaring 
>a variable explicitly is better than just implicitly using, seemingly arbitrary, ones.
>
>Please note that by "declaring" I don't mean like in C/C++ and others where you 
>associate an object type with a variable name. Why would I do that, that's not very 
>pythonic, is it? I'm only after the declaring of the variable _name_ before it is 
>used (e.g. a keyword "var" or something).
>
You might like the effect of __slots__ = ... in class definitions.
See

    http://www.python.org/doc/current/whatsnew/sect-rellinks.html

just above the section 2.5 header (or just search for __slots__)

Regards,
Bengt Richter




More information about the Python-list mailing list