PROPOSAL: [].__doc__, "".__doc__, ...

Ben Wolfson rumjuggler at home.com
Tue Feb 22 19:34:52 EST 2000


On Tue, 22 Feb 2000 20:52:00 +0100, Gerrit Holl <gerrit.holl at pobox.com>
wrote:

><quote name="François Pinard" date="951154699">
>> Gerrit Holl <gerrit.holl at pobox.com> writes:
>> 
>> > I think it would be a nice feature for all types with methods to have
>> > docstrings describing the methods, so [].__doc__ would be a string with
>> > the descripion of .index, .append... etc.
>> 
>> It already works, at least partly:
>> 
>>    >>> print [].append.__doc__
>>    L.append(object) -- append object to end
>
>I know.
>
>> Still, `print [].__doc__' raises an exception.
>
>I know. That's what I mean :)

>>> for method in dir([]):
	exec "print [].%s.__doc__" % method

L.append(object) -- append object to end
L.count(value) -> integer -- return number of occurrences of value
L.extend(list) -- extend list by appending list elements
L.index(value) -> integer -- return index of first occurrence of value
L.insert(index, object) -- insert object before index
L.pop([index]) -> item -- remove and return item at index (default last)
L.remove(value) -- remove first occurrence of value
L.reverse() -- reverse *IN PLACE*
L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1



More information about the Python-list mailing list