[NEWBIE] Sequence indices & method docstrings
Duncan Booth
duncan at rcp.co.uk
Mon Sep 4 08:44:46 EDT 2000
p.agapow at ic.ac.uk (Paul-Michael Agapow) wrote in
<1egfqnh.1biw837161s15iN%p.agapow at ic.ac.uk>:
>Point the second: in a set of container classes I'm implementing, I have
>some synonym methods, i.e. methods with different names that just call
>the other implemented function. Ideally, these should share the same
>docstring, but instead of just copying it, I thought it would be easy to
>just put in:
>
>class MyQueue:
> def push (self, item):
> """The docstring for push!"""
> # blah, blah, blah ...
>
> def enqueue (self, item):
> __class__.push.__doc__
> # just a synomym
> self.push (item)
>
>... which didn't work. Other possibilities included:
>
> enqueue.__doc__ = push.__doc__
>
Is there a good reason why you don't just do this?
class MyQueue:
def push (self, item):
"""The docstring for push!"""
# blah, blah, blah ...
enqueue = push
More information about the Python-list
mailing list