Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '21,': 0.07; 'subject:Why': 0.09; 'subject:string': 0.09; 'subject:not': 0.11; 'aug': 0.13; 'docstring': 0.16; 'empty.': 0.16; 'expression.': 0.16; 'literal,': 0.16; 'subject:doc': 0.16; 'wrote:': 0.17; 'doc': 0.22; 'work,': 0.22; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'wonder': 0.27; 'message-id:@mail.gmail.com': 0.27; 'this?': 0.28; '>>>>': 0.29; 'class': 0.29; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'do:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Z6gevpRo3Y/C0+HasKaa9t2I4oA+DmaQdFwUL8E2Jhg=; b=RshS2nGS/vLkSgSt8BlRBGjpSa1yRUaNK/Py3kDcnSKtI7gSgfCVTVIotUjbKs2fpH deKc76YT6iphiSYaVw/vYDYmMNmDuOnw+Xr2zRmc5f7z/9elx0DCRKvJQ033Ns3TPV/2 jfmTSQvuwWk+nBM9PwqFsAbqC4+KvJFM3um5ttTVSJThjsoeDLVRZCdX8UQUADpUEoEj w2uBsKqrMkSv9Q8vtpd3GnRmR3/NyhVsarrBOwooyYZhIGvwrdPb/EueL1FMofrxlcSr BaOY5t5pPrueiG68vhX4MWC2XrZWZpXnKnwl1PSzKv+j2nIwjv88dN1iz0apJKlQ9/T7 gZ9g== MIME-Version: 1.0 In-Reply-To: <3a128081-7f5d-4641-bc5d-8cffe64f5eee@googlegroups.com> References: <3a128081-7f5d-4641-bc5d-8cffe64f5eee@googlegroups.com> From: Ian Kelly Date: Tue, 21 Aug 2012 11:09:58 -0600 Subject: Re: Why does dynamic doc string do not work? To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345569033 news.xs4all.nl 6879 [2001:888:2000:d::a6]:36458 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27577 On Tue, Aug 21, 2012 at 10:44 AM, Miki Tebeka 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.