Documenting builtin methods
Ben Finney
ben+python at benfinney.id.au
Wed Jul 10 23:57:06 EDT 2013
Joshua Landau <joshua at 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 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.
A good way to do this would be to show some actual code that
demonstrates the surprising behaviour (you may need to post using a
service that doesn't munge your text), along with the traceback if any.
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.
--
\ Q: “I've heard that Linux causes cancer...” Torvalds: “That's a |
`\ filthy lie. Besides, it was only in rats and has not been |
_o__) reproduced in humans.” —Linus Torvalds |
Ben Finney
More information about the Python-list
mailing list