__name__ becoming read-write?

Arthur ajsiegel at optonline.com
Mon Aug 23 17:00:43 CEST 2004


On 23 Aug 2004 16:50:22 +0200, Hallvard B Furuseth
<h.b.furuseth at usit.uio.no> wrote:

>Arthur wrote:
>
>> Did I hallucinate something about __name__ becoming read-write?
>
>_Becoming_ read-write?  When was it read-only?
>
>Python 1.5.2 (#1, Jul 14 2004, 20:34:28)  [GCC 3.2.3] on sunos5
>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>> class foo: pass
>... 
>>>> foo.__name__ = 'bar'
>>>> foo.__module__ = 'baz' 
>>>> foo
><class baz.bar at c5ee0>

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
on win32
>>> def foo():
	pass

>>> foo.__name__='bar'

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in -toplevel-
    foo.__name__='bar'
TypeError: readonly attribute

I hope I'm not being stupid.

And what's with running 1.5.2 ;)

Art



More information about the Python-list mailing list