Why does dynamic doc string do not work?

Miki Tebeka miki.tebeka at gmail.com
Tue Aug 21 13:40:04 EDT 2012


Thanks!
> On 08/21/2012 12:44 PM, Miki Tebeka wrote:
>> > <snip>
>> >>> class B:
>> > ... '''a {} string'''.format('doc')
>> > ... 
>> >>>> B.__doc__
>> >>>>
>> > <snip> I wonder why the first B docstring is empty. Thanks, -- Miki
>>>> According to some early documentation:
>>>> "convenient initialization of the |__doc__| attribute of modules,
>> classes and functions by placing a string literal by itself as the first
>> statement in the suite. It must be a literal -- an expression yielding a
>> string object is not accepted as a documentation string, since future
>> tools may need to derive documentation from source by parsing."
>>>> -- 
>>>> DaveA



More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /