On Tue, Aug 21, 2012 at 10:44 AM, Miki Tebeka <miki.teb...@gmail.com> wrote:
> 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.

The docstring is built at compile-time, not at run-time, so it must be
a literal, not an arbitrary expression.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to