Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #27577
| 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 | <ian.g.kelly@gmail.com> |
| 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 <ian.g.kelly@gmail.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3607.1345569033.4697.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
On Tue, Aug 21, 2012 at 10:44 AM, Miki Tebeka <miki.tebeka@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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why does dynamic doc string do not work? Miki Tebeka <miki.tebeka@gmail.com> - 2012-08-21 09:44 -0700
Re: Why does dynamic doc string do not work? Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-21 11:09 -0600
Re: Why does dynamic doc string do not work? MRAB <python@mrabarnett.plus.com> - 2012-08-21 18:16 +0100
Re: Why does dynamic doc string do not work? Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-21 11:21 -0600
Re: Why does dynamic doc string do not work? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-21 17:22 +0000
Re: Why does dynamic doc string do not work? Dave Angel <d@davea.name> - 2012-08-21 13:30 -0400
Re: Why does dynamic doc string do not work? Miki Tebeka <miki.tebeka@gmail.com> - 2012-08-21 10:40 -0700
Re: Why does dynamic doc string do not work? Miki Tebeka <miki.tebeka@gmail.com> - 2012-08-21 10:40 -0700
csiph-web