README.rst: Add detail to example

This shows more details of the the
`funcsigs.Signature` object and adds syntax
highlighting to the example.
This commit is contained in:
Marc Abramowitz 2015-02-19 11:32:11 -08:00 committed by Robert Collins
parent d131c4af91
commit 6cea81cced
1 changed files with 10 additions and 2 deletions

View File

@ -46,13 +46,21 @@ Example
-------
To obtain a signature object, pass the target function to the
``funcsigs.signature`` function. ::
``funcsigs.signature`` function.
.. code-block:: python
>>> from funcsigs import signature
>>> def foo(a, b=None, *args, **kwargs):
... pass
...
>>> sig = signature(foo)
>>> sig
<funcsigs.Signature object at 0x...>
>>> sig.parameters
OrderedDict([('a', <Parameter at 0x... 'a'>), ('b', <Parameter at 0x... 'b'>), ('args', <Parameter at 0x... 'args'>), ('kwargs', <Parameter at 0x... 'kwargs'>)])
>>> sig.return_annotation
<class 'funcsigs._empty'>
Introspecting callables with the Signature object