[Python-Dev] Writable doc (original) (raw)
Noufal Ibrahim noufal at nibrahim.net.in
Thu Jan 19 06:07:30 CET 2012
- Previous message: [Python-Dev] Writable __doc__
- Next message: [Python-Dev] Writable __doc__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Sreenivas Reddy T <thatiparthysreenivas at gmail.com> writes:
this is happening on python 2.6 too.
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.
class Test(type): ... doc= File "", line 2 doc= ^ SyntaxError: invalid syntax class Test(type): ... doc='asasdas' ...
I don't get any syntax errors (Python2.7 and 2.6)
class Test(object): ... doc = "Something" ...
help(Test)
class Test(type): ... doc = "something" ... help(Test)
Test.doc 'something'
Test.doc='sadfsdff' Traceback (most recent call last): File "", line 1, in AttributeError: attribute 'doc' of 'type' objects is not writable type(Test) <type 'type'>
The name, bases, module, abstractmethods, dict and doc attributes have custom getters and setters in the type object definition. doc has only a getter. No setter and no deleter.
http://hg.python.org/cpython/file/0b5ce36a7a24/Objects/typeobject.c#l658
That is why you're seeing this. What's the question here?
[...]
-- ~noufal http://nibrahim.net.in
May I ask a question?
- Previous message: [Python-Dev] Writable __doc__
- Next message: [Python-Dev] Writable __doc__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]