variable declaration

Alex Martelli aleaxit at yahoo.com
Mon Feb 7 17:34:09 EST 2005


Alexander Zatvornitskiy
<Alexander_Zatvornitskiy at p131.f3.n5025.z2.fidonet.org> wrote:

> ?????? Alex!
> 
> 05 ??????? 2005 ? 17:00, Alex Martelli ? ????? ?????? ? All ?????:
>  >>  AM> The fact that in Python there are ONLY statements, NO
>  >>  AM> declarations,
>  >> What is "global"? Statement? Ok, I fill lack of "var" statement:)
>  AM> 'global' is an ugly wart,
> 
> Ok,
> ===
> def hi():
>   print "hello!"
> ===
> What is it? Statement or declaration?

Statement, obviously.

> After interpreter see this lines, it add
> information about function "hi" and it's body to his memory. Look at this:

Utterly false, like most of the unqualified, arrogant assertions you
keep making.

If and when the interpreter *EXECUTES* this *STATEMENT*, it binds or
rebinds name 'hi' in the current scope to a new function object -- just
like it would if the statement was, say, an assignment such as:

hi = new.function( ... )

with the appropriate arguments.  So, wondering if `def' "is a
declaration" is just about as stupid as wondering if an assignment
statement "is a declaration".

If the statement is not EXECUTED -- it does not suffice for it to be
merely *SEEN*, and your assertion about this is pure and unadulterated
POPPYCOCK, just like everything else you've been posting -- then no new
function object is made, and nothing is bound or re-bound to name 'hi'
in the current scope -- for 'def' just as for assignment, same thing.

If either statement is executed repeatedly, it builds a new function
object each time.  Not particularly meaningful when the function object
is trivial in this way, but if it was at all significant that would be
easy to verify -- just give the function some meaningfully mutable
values, such as argument defaults, and you can mutate each independent
function object separately at will.

'global', of course, is, alas, totally different -- which makes it a
wart.


>   var S
> Interpreter see this line and add information about variable S to the
> memory. I don't find big difference.

That's because you criticize what you completely fail to understand, and
your arrogance is such that you appear to not feel any need to perform a
modicum of research to avoid showing everybody your total ignorance
coupled with perfect willingness to spout about subjects you don't
grasp.

> By the way keyword "def" is as bad as "var", from your point of view? :)

Obviously not: 'def' is an excellent executable statement, just like
'class' or assignment.  'var' is (or rather, thank Guido, WOULD BE, if
Python developers were as incompetent and incapable as you) reason
enough to throw the language in the closest dustbin.

> Do you ever wrote programs for engineering calculations? Dozens of
variables

I was a senior developer for a major CAD SW house for 12 years, rising
to the rank of "senior software consultant".  Engineering enough for
you?

> with names like lambda_1, phi_k, epsilon, d2f_dx2, grad_z and so on. You
wrote

Not when _I_ wrote the code.  Clarity of naming is always important,
whether the computations are "engineering", "accounting", or whatever.

> You may say: give better names for your variables! Ha, I'am often don't
> understand that they mean! They are written for me by an engineer! He is

A good programmer understand what he or she IS programming.  I am not
surprised that you're used to coding without a glimmer of comprehension:
your readiness to publically post unfounded criticisms of a language
about which you're most obviously totally clueless clearly show that
doing without comprehending is something you're quite used to.

>  AM> wrong (just incredible, eh?!); others have gone away to find their
>  AM> bliss in Perl, PHP, or whatever -- good riddance, and don't let the
>  AM> door slam behind you as you go, please.
> 
> Don't be so ... I don't find the equivalent english word. Smth like: Take it
> more easy.

Don't have much experience with Southern Europeans of hot Latin blood,
hm?  We're ALWAYS intense about our feelings.  Of course, afterwards we
go bask in our delightful weather sipping our delightful cheap wines, so
there's no risk of our lives being stressful -- it must be very
different in the frozen North.


Alex



More information about the Python-list mailing list