Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50408

Re: Documenting builtin methods

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'interpreter': 0.05; 'that?': 0.05; 'attribute': 0.07; 'duplicate': 0.07; 'string': 0.09; 'literal': 0.09; 'newline': 0.09; 'raises': 0.09; 'cc:addr :python-list': 0.11; 'any.': 0.16; 'caching': 0.16; "can't.": 0.16; 'collections': 0.16; 'cryptic': 0.16; 'deque': 0.16; 'did.': 0.16; 'expecting': 0.16; 'finney': 0.16; 'iterator': 0.16; 'really?': 0.16; 'surprising': 0.16; 'unhappy': 0.16; 'writable': 0.16; '(you': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'obviously': 0.18; 'trying': 0.19; 'normally': 0.19; 'small,': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'of.': 0.24; 'fairly': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'possibly': 0.26; 'right.': 0.26; 'post': 0.26; 'code:': 0.26; 'header:In- Reply-To:1': 0.27; "doesn't": 0.30; 'errors': 0.30; 'message- id:@mail.gmail.com': 0.30; 'along': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; 'getting': 0.31; 'that.': 0.31; 'crash': 0.31; 'remotely': 0.31; 'writes:': 0.31; 'run': 0.32; 'guess': 0.33; 'actual': 0.34; 'skip:d 20': 0.34; "i'd": 0.34; 'could': 0.34; "can't": 0.35; 'objects': 0.35; 'test': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'shorter': 0.36; "didn't": 0.36; 'seconds': 0.37; 'list': 0.37; 'ben': 0.38; 'work?': 0.38; 'expect': 0.39; 'explain': 0.39; 'does': 0.39; "couldn't": 0.39; 'sure': 0.39; 'either': 0.39; 'how': 0.40; 'removing': 0.60; 'then,': 0.60; 'simply': 0.61; 'simple': 0.61; "you're": 0.61; "you've": 0.63; 'show': 0.63; 'such': 0.63; 'july': 0.63; 'here': 0.66; 'obvious': 0.74; 'surprise': 0.74; 'comment.': 0.84; 'demonstrates': 0.84; 'different.': 0.84; 'observed': 0.84; 'tone': 0.84; 'yielded': 0.84; 'convenience,': 0.91; 'response,': 0.91; 'imagine': 0.93; 'yourself,': 0.95; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=rFPM3nRqJ/EQMS/g/37RDjsa7PTtYWcXTEQhEiV6bs4=; b=VvskTxGYf6DC43fGgsnaW4G/+E1ZarAFQeH/hJ8Go/ocxRh+2tHk38W6zGJYI3Unvo Zjbb27Sq7clGj+bj1Sr+q/6HoK2eC8AaBwCP4uV0hoRZG63WOZizUTqbJQJ6dFf1k4Oh hvYDfrgGqDRRnVudQjf9hCji53bw1gNRo4WOfjLDYIC99EX00xXzPS1OnuZnE3F5oYkw 26wv9UrKmEh/PVSgdmA4GIsYEtDrx5tkPJaFdi2FI9zym2SXebjScipwvcjtAxZyEVW0 Z2ryxONjjG5Zr22l1fQVw3GCGEasV0Com6GhrKMS07AQp8KkfV8EeJc2bxygDoubmqxL Eg5w==
X-Received by 10.152.121.73 with SMTP id li9mr16600589lab.42.1373516070214; Wed, 10 Jul 2013 21:14:30 -0700 (PDT)
MIME-Version 1.0
Sender joshua.landau.ws@gmail.com
In-Reply-To <7wk3kxsq99.fsf@benfinney.id.au>
References <CAN1F8qVbECK_xsH-umbdzw1WfUv=y2K0Poy6Yj=q5OWBpEjavA@mail.gmail.com> <7wk3kxsq99.fsf@benfinney.id.au>
From Joshua Landau <joshua@landau.ws>
Date Thu, 11 Jul 2013 05:13:50 +0100
X-Google-Sender-Auth osQnC0_LaMnLcLR9vCAL6AlRb8M
Subject Re: Documenting builtin methods
To Ben Finney <ben+python@benfinney.id.au>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.4561.1373516078.3114.python-list@python.org> (permalink)
Lines 63
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373516078 news.xs4all.nl 15921 [2001:888:2000:d::a6]:59397
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50408

Show key headers only | View raw


On 11 July 2013 04:57, Ben Finney <ben+python@benfinney.id.au> wrote:
> Joshua Landau <joshua@landau.ws> writes:
>
>> I have this innocent and simple code:
>>
>> from collections import deque
>> exhaust_iter = deque(maxlen=0).extend
>> exhaust_iter.__doc__ = "Exhaust an iterator efficiently without
>> caching any of its yielded values."
>>
>> Obviously it does not work.
>
> Right. It raises a SyntaxError because you've got a simple string
> literal that isn't closed before the end of the line.

Is removing one newline such a big deal to you really?

>> Is there a way to get it to work simply
>
> What behaviour would you expect from that? We can't guess what you mean
> by “get it to work” unless we know what you're expecting and how the
> observed behaviour is different.

Obviously I want to set .__doc__. What else could you possibly glean
from me trying to set .__doc__? Are you that far away from an
interpreter that you can't see that it doesn't work?

> A good way to do this would be to show some actual code that
> demonstrates the surprising behaviour

That's what I did.

> (you may need to post using a
> service that doesn't munge your text), along with the traceback if any.

I imagine you could've run it yourself, seeing as it's a small,
reproducible test sample.

> Then, show a session that behaves the way you'd expect it to behave, and
> we can explain either how to achieve that or why it can't.

You know, I'd like it to not crash. And do what it would normally do
if it didn't crash.


I'm not sure why you've given this response, as my question was fairly
explanatory given that you spend the 10 seconds to run the code if you
couldn't see the crash by eye. It's a whole lot shorter than the time
you spent on the comment. There are a lot of people who post beasts of
code to this list that isn't remotely runnable and with cryptic
cropped errors that you have no obvious way of getting a duplicate of.
I did not do that.

For convenience, and because despite my tone of surprise I hold no
grudge or disdain, here is the relevant part of the traceback:
AttributeError: attribute '__doc__' of 'builtin_function_or_method'
objects is not writable

If you're still unhappy about the text-wrapping:
from collections import deque
exhaust_iter = deque(maxlen=0).extend
exhaust_iter.__doc__ = "Exhaust an iterator efficiently"

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Documenting builtin methods Joshua Landau <joshua@landau.ws> - 2013-07-11 05:13 +0100

csiph-web