[Python-Dev] readonly doc (original) (raw)
Daniel Fetchinson fetchinson at googlemail.com
Thu Oct 22 19:00:51 CEST 2009
- Previous message: [Python-Dev] readonly __doc__
- Next message: [Python-Dev] readonly __doc__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Speaking of the doc property, I just noticed the following thing on py3k:
class C: pass ... C.doc = "hop" Traceback (most recent call last): File "", line 1, in AttributeError: attribute 'doc' of 'type' objects is not writable
Happens also with new style classes in python 2.x:
Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
class C(object): pass ... C.doc = 'hello' Traceback (most recent call last): File "", line 1, in AttributeError: attribute 'doc' of 'type' objects is not writable
But not with old style classes:
Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
class C: pass ... C.doc = 'hello'
Cheers, Daniel
-- Psss, psss, put it down! - http://www.cafepress.com/putitdown
- Previous message: [Python-Dev] readonly __doc__
- Next message: [Python-Dev] readonly __doc__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]