diff options
| author | Michele Simionato <michele.simionato@gmail.com> | 2015-07-22 13:55:56 +0200 |
|---|---|---|
| committer | Michele Simionato <michele.simionato@gmail.com> | 2015-07-22 13:55:56 +0200 |
| commit | c654f80ca9d4770c09aaa622844893a493cbc19f (patch) | |
| tree | 18a8f224d7042905cd94c085439e24eba6b6645c /src | |
| parent | fb545895801ade0d17192d33460f7819ed97d358 (diff) | |
| download | python-decorator-git-c654f80ca9d4770c09aaa622844893a493cbc19f.tar.gz | |
Added a note on FunctionMaker.create
Diffstat (limited to 'src')
| -rw-r--r-- | src/tests/documentation.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/tests/documentation.py b/src/tests/documentation.py index 8282063..cdee30f 100644 --- a/src/tests/documentation.py +++ b/src/tests/documentation.py @@ -535,6 +535,19 @@ the names of the mandatory arguments) an attribute ``arg0``, ``arg1``, ..., ``argN`` is also generated. Finally, there is a ``signature`` attribute, a string with the signature of the original function. +Notice: you should not pass signature strings with default arguments, +i.e. something like 'f1(a, b=None)'. Just pass 'f1(a, b)' and then +a tuple of defaults: + +.. code-block:: python + + >>> f1 = FunctionMaker.create( + ... 'f1(a, b)', 'f(a, b)', dict(f=f), addsource=True, defaults=(None,)) + >>> import inspect + >>> print(inspect.getargspec(f1)) + ArgSpec(args=['a', 'b'], varargs=None, keywords=None, defaults=(None,)) + + Getting the source code --------------------------------------------------- @@ -553,7 +566,6 @@ $$example .. code-block:: python - >>> import inspect >>> print(inspect.getsource(example)) def wrapper(*args, **kw): return func(*args, **kw) |
