declaration of variables?
tatsujin at spamgoeshere.despammed.om
Sun Feb 16 20:24:21 CET 2003
Alex Martelli wrote:
>>:-) I mostly meant that Python seems more "aware" than most other
>>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).
(perhaps I was a bit unclear about this, for me it was implicit (uhm))
> Do you really fail to see how not having to declare variables enhances
> flexibility? Has your brain been washed SO thoroughly that you can't
> see it any longer, or are you just applying less than ALL of your brain
> to the issue? Take it as a stimulus to personal growth -- use advanced
> google groups search to find the hundreds of times this has been already
> discussed in this group over the years, for example, making it a research
> project rather than asking for the info to be spoon-fed to you (for the
> N-plus-1'th time in this group's history).
See my comment above. As you suggested (ordered?), I did a little googling and I must
say I couldn't find any good arguments for allowing implicit creation of variable names.
If you by flexibility mean it could be used for creating variable names in run-time
for things that are not known at the time of writing, sure, but in that case a
dictionary is of course a better choice.
I refrain from making any comments to rant about unit-tests, because I feel it
[cw]ould get long-winded, and is kind of beside the point I'm trying to make.
More information about the Python-list