można po prostu użyć polecenia help()
, aby uzyskać pomoc dotyczącą wbudowanych funkcji oraz kodu.
dla np: jeśli chcesz zobaczyć kod str(), wystarczy wpisać - help(str)
powróci tak,
>>> help(str)
Help on class str in module __builtin__:
class str(basestring)
| str(object='') -> string
|
| Return a nice string representation of the object.
| If the argument is a string, the return value is the same object.
|
| Method resolution order:
| str
| basestring
| object
|
| Methods defined here:
|
| __add__(...)
| x.__add__(y) <==> x+y
|
| __contains__(...)
| x.__contains__(y) <==> y in x
|
| __eq__(...)
| x.__eq__(y) <==> x==y
|
| __format__(...)
| S.__format__(format_spec) -> string
|
| Return a formatted version of S as described by format_spec.
|
| __ge__(...)
| x.__ge__(y) <==> x>=y
|
| __getattribute__(...)
-- More --
Czy możesz podać przykład z 'wyliczeniem'? – Benjamin
Można sprawdzić sposób testowania wyliczenia wbudowanego [tutaj] (http://hg.python.org/cpython/file/b36cb4602e21/Lib/test/test_enumerate.py). – Makoto
kod wyliczeniowy to [tutaj] (http://svn.python.org/view/python/trunk/Objects/enumobject.c?view=markup) –