Would it be too much trouble to prevent replacing double-underscore attributes like __name__ and __file__? I'll accept a "consenting adults" argument -- it's just that somehow this makes me uneasy: Python 1.5.2 (#54, Jul 14 1999, 12:50:51) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import foo >>> foo.__name__ 'bar' >>> foo.__file__ 'bar.py' >>> foo <module 'bar' from 'bar.py'> Of course, there is no 'bar.py'. 'foo.py' just contains __file__ = 'bar.py' __name__ = 'bar' (If you say i deserved to be punished for such heresy, fine...) -- ?!ng
Would it be too much trouble to prevent replacing double-underscore attributes like __name__ and __file__?
This can be handy sometimes.
I'll accept a "consenting adults" argument -- it's just that somehow this makes me uneasy:
OK - accept it :-) Just dont do it if it makes you uneasy.
>>> import foo >>> foo.__name__ 'bar' >>> foo.__file__ 'bar.py' >>> foo <module 'bar' from 'bar.py'>
That is no worse than, say:
a=1 globals()['a']=2 a 2
So you could make the same argument that globals() should be read-only, to force you to do the "normal" thing. To me, this is one of Python's big features. I dont want it holding my hand so tightly it cuts circulation :-) Mark.
On Fri, 2 Jun 2000, Ka-Ping Yee wrote:
Would it be too much trouble to prevent replacing double-underscore attributes like __name__ and __file__?
Well, special casing seems like a bad idea on the face of it. Where does it stop? The correct way to "solve" this, is to add declarations to Python, including "constant" declaration, and then saying that __name__ and __file__ are "implicitly declared" constants. please-scatter-IMHOs-generously-throughtout-the-mail-ly y'rs, Z. -- Moshe Zadka <moshez@math.huji.ac.il> http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com
participants (3)
-
Ka-Ping Yee
-
Mark Hammond
-
Moshe Zadka