Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50488
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Documenting builtin methods |
| Date | 2013-07-12 13:43 +1000 |
| Organization | A noiseless patient Spider |
| Message-ID | <krntld$h9o$1@dont-email.me> (permalink) |
| References | <mailman.4558.1373512579.3114.python-list@python.org> <51de4b6c$0$11094$c3e8da3@news.astraweb.com> <mailman.4603.1373584321.3114.python-list@python.org> |
On 12/07/2013 9:11 AM, Joshua Landau wrote:
> I also feel that:
>
> def factory():
> eatit = deque(maxlen=0).extend
> def exhaust_iter(it):
> """Doc string goes here"""
> eatit(it)
> return exhaust_iter
>
> exhaust_it = factory()
> del factory
>
> is a very unobvious way to change a docstring and hides what I'm doing
> very effectively.
My last post seems to have been eaten by either Thunderbird or the
EternalSeptember servers, but it contained an erroneous claim that the
straight function version performed as well as the factory one. However,
in the interim a co-worker has come up with a slightly faster variant:
from functools import partial
from collections import deque
class exhaust_it(partial):
"""custom doc string"""
exhaust_it = exhaust_it(deque(maxlen=0).extend)
Shadowing the class name with the partial instance will ensure it has
the same name when accessed via help(), and it's a simple way to avoid
needing to clean up the namespace, as well.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Documenting builtin methods Joshua Landau <joshua@landau.ws> - 2013-07-11 04:15 +0100
Re: Documenting builtin methods alex23 <wuwei23@gmail.com> - 2013-07-11 15:35 +1000
Re: Documenting builtin methods Steven D'Aprano <steve@pearwood.info> - 2013-07-11 06:06 +0000
Re: Documenting builtin methods Chris Angelico <rosuav@gmail.com> - 2013-07-11 17:06 +1000
Re: Documenting builtin methods Steven D'Aprano <steve@pearwood.info> - 2013-07-11 07:15 +0000
Re: Documenting builtin methods Chris Angelico <rosuav@gmail.com> - 2013-07-11 17:23 +1000
Re: Documenting builtin methods Joshua Landau <joshua@landau.ws> - 2013-07-12 00:11 +0100
Re: Documenting builtin methods alex23 <wuwei23@gmail.com> - 2013-07-12 13:43 +1000
Re: Documenting builtin methods Joshua Landau <joshua@landau.ws> - 2013-07-12 08:09 +0100
csiph-web