is this a valid import sequence ?

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sun Jun 24 07:29:08 EDT 2007


On Sat, 23 Jun 2007 21:11:42 -0700, Alex Martelli wrote a lot, with lots
of YELLING.

Wow. 

What can I say?

Given the amount of SHOUTING in your post, and the fact that you feel so
strongly about the trivial question of the redundant use of the global
statement that you would "fail a student" who did it -- even if they did
everything else correctly, efficiently and elegantly -- it seems to me
that you are beyond rational discussion on this subject. 

Perhaps you should consider writing a PEP to make the redundant use of the
global statement a compile-time error? Then there would be absolutely
no doubt in anyone's mind that it is _wrong_ (and not just unnecessary or
redundant) to use the global statement in the circumstances discussed. 

Then we can move on to removing floats of the form 1.e0, unary-plus on
numeric types, and string-slices like s[:].

I'm not sure where you got the idea that I'm "encouraging newbies to
overuse globals", when I wrote in an earlier post to this same thread: 

"However, using global variables is almost always a bad idea. Passing
parameters around is really cheap in Python, that's almost always a better
solution."

If you manage to calm down enough to answer without exaggerating and
misrepresenting my views, I would like to hear your opinion of whether the
following two functions are equally as wrong:

def f1(gizmo):
    global spam # holds the frommet needed for the gizmo
    gizmo.get_frommet(spam)

def f2(gizmo):
    # global spam holds the frommet needed for the gizmo
    gizmo.get_frommet(spam)

I'm sure they're both wrong, but I'd like to know if there are degrees of
wrongness.



-- 
Steven.




More information about the Python-list mailing list