declaration of variables?

Alex Martelli aleaxit at yahoo.com
Sun Feb 16 09:46:20 EST 2003


André Jonsson wrote:

> Jp Calderone wrote:
>>   "enlightened" language?  Hrm.  Dynamic, sure... OO, okay... functional,
>> sometimes!  But "enlightened"?
> 
> :-)  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.

> Flexibility? Please explain. To me this just seem error-prone, and a pain
> in the b*tt.

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).


> Also, it may not even be possible to detect by a unit-test, because there
> may not be a syntactical error or such that would cause a run-time error,
> it just "behaves" strangely (see my example of a _very_ simple case). In a

You don't seem to know what unit-tests *ARE*.  The purpose of unit tests
is not chiefly to elicit syntax errors, or even run-time errors, but
rather mainly just the think you claim it's impossible for them to do --
elicit and detect strange behavior!

Again, take this as a stimulus to personal growth: find out (e.g. using
Google) what exactly are unit tests, and why your "not even possible to
detect by a unit-test" above is SO weird.  Why an alleged unit-test that
doesn't detect all typoes typically detected by languages which force you
to declare variables is such a travesty that you should never rely on
any software whose "testing" is SO feeble...


> larger program/project this could get kinda complex. But I guess that kind
> of stuff aren't supposed to be done in Python then...

You guess wrong.  Particularly thanks to the power of unit tests, larger
programs and projects ARE, not only "supposed to be done", but actually
done and quite successfully too.


> But it appears that pychecker reports this kind of stuff so I'll quit
> complaining now...  :-)

PyChecker is good, but those "larger programs and projects" often to not
rely on it at all.  They DO almost invariably rely on good unit tests,
though (often to the point of writing unit tests BEFORE the code they
are going to test -- so-called "test-first coding").


Alex





More information about the Python-list mailing list