Why does dynamic doc string do not work?

Miki Tebeka miki.tebeka at gmail.com
Tue Aug 21 12:44:10 EDT 2012


Greetings,

>>> class A:
...     '''a doc string'''
... 
>>> A.__doc__
'a doc string'
>>> class B:
...     '''a {} string'''.format('doc')
... 
>>> B.__doc__
>>> 

Is there's a reason for this?

I know I can do:
>>> class B:
...    __doc__ = '''a {} string'''.format('doc')

And it'll work, but I wonder why the first B docstring is empty.

Thanks,
--
Miki



More information about the Python-list mailing list