Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 | 1 |
2 :mod:`inspect` --- Inspect live objects | 2 :mod:`inspect` --- Inspect live objects |
3 ======================================= | 3 ======================================= |
4 | 4 |
5 .. module:: inspect | 5 .. module:: inspect |
6 :synopsis: Extract information and source code from live objects. | 6 :synopsis: Extract information and source code from live objects. |
7 .. moduleauthor:: Ka-Ping Yee <ping@lfw.org> | 7 .. moduleauthor:: Ka-Ping Yee <ping@lfw.org> |
8 .. sectionauthor:: Ka-Ping Yee <ping@lfw.org> | 8 .. sectionauthor:: Ka-Ping Yee <ping@lfw.org> |
9 | 9 |
10 | 10 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 | 497 |
498 | 498 |
499 .. function:: getmro(cls) | 499 .. function:: getmro(cls) |
500 | 500 |
501 Return a tuple of class cls's base classes, including cls, in method resoluti on | 501 Return a tuple of class cls's base classes, including cls, in method resoluti on |
502 order. No class appears more than once in this tuple. Note that the method | 502 order. No class appears more than once in this tuple. Note that the method |
503 resolution order depends on cls's type. Unless a very peculiar user-defined | 503 resolution order depends on cls's type. Unless a very peculiar user-defined |
504 metatype is in use, cls will be the first element of the tuple. | 504 metatype is in use, cls will be the first element of the tuple. |
505 | 505 |
506 | 506 |
507 .. function:: getcallargs(func[, *args][, **kwds]) | 507 .. function:: getcallargs(func[, *args][, **kwds]) |
Benjamin
2010/03/20 03:14:31
I would like to see it documented that
a) getcall
George Sakkis
2010/03/20 13:26:34
Done.
| |
508 | 508 |
509 Get the mapping of arguments to values when calling ``func(*args, **kwds)``. | 509 Bind the *args* and *kwds* to the argument names of the Python function or |
Benjamin
2010/03/20 03:14:31
How about "Bind the *args*, and *kwds* to the argu
George Sakkis
2010/03/20 13:26:34
Done.
| |
510 | 510 method *func*, as if it was called with them. For bound methods, bind also th e |
511 A dict is returned, with keys the function argument names (including the | 511 first argument (typically named ``self``) to the associated instance. A dict |
Benjamin
2010/03/20 03:14:31
This can be in the same paragraph as the first phr
George Sakkis
2010/03/20 13:26:34
Done.
| |
512 names of the ``*`` and ``**`` arguments, if any), and values the respective | 512 is returned, mapping the argument names (including the names of the ``*`` and |
513 bound values from ``args`` and ``kwds``. For example:: | 513 ``**`` arguments, if any) to their values from *args* and *kwds*. In case of |
514 invoking *func* incorrectly, i.e. whenever ``func(*args, **kwds)`` would rais e | |
515 an exception because of incompatible signature, an exception of the same type | |
516 and the same or similar message is raised. For example:: | |
514 | 517 |
515 >>> from inspect import getcallargs | 518 >>> from inspect import getcallargs |
Benjamin
2010/03/20 03:14:31
I don't think this line is needed.
George Sakkis
2010/03/20 13:26:34
You mean the import? It's used in other docs thoug
| |
516 >>> def f(a, b=1, *pos, **named): | 519 >>> def f(a, b=1, *pos, **named): |
517 ... pass | 520 ... pass |
518 >>> getcallargs(f, 1, 2, 3) | 521 >>> getcallargs(f, 1, 2, 3) |
519 {'a': 1, 'named': {}, 'b': 2, 'pos': (3,)} | 522 {'a': 1, 'named': {}, 'b': 2, 'pos': (3,)} |
520 >>> getcallargs(f, a=2, x=4) | 523 >>> getcallargs(f, a=2, x=4) |
521 {'a': 2, 'named': {'x': 4}, 'b': 1, 'pos': ()} | 524 {'a': 2, 'named': {'x': 4}, 'b': 1, 'pos': ()} |
522 >>> getcallargs(f) | 525 >>> getcallargs(f) |
523 Traceback (most recent call last): | 526 Traceback (most recent call last): |
524 ...···· | 527 ...···· |
525 TypeError: f() takes at least 1 argument (0 given) | 528 TypeError: f() takes at least 1 argument (0 given) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 call on the stack. | 612 call on the stack. |
610 | 613 |
611 | 614 |
612 .. function:: trace([context]) | 615 .. function:: trace([context]) |
613 | 616 |
614 Return a list of frame records for the stack between the current frame and th e | 617 Return a list of frame records for the stack between the current frame and th e |
615 frame in which an exception currently being handled was raised in. The first | 618 frame in which an exception currently being handled was raised in. The first |
616 entry in the list represents the caller; the last entry represents where the | 619 entry in the list represents the caller; the last entry represents where the |
617 exception was raised. | 620 exception was raised. |
618 | 621 |
LEFT | RIGHT |