Skip to content

Instantly share code, notes, and snippets.

Created January 5, 2016 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3d97523517abe0f55dc9 to your computer and use it in GitHub Desktop.
Save anonymous/3d97523517abe0f55dc9 to your computer and use it in GitHub Desktop.
IPython3 1.2.1 from Ubuntu.
>>> import functools, IPython
>>> IPython.version_info
(1, 2, 1, '')
>>> def args_as_ints(func):
... @functools.wraps(func)
... def wrapper(*args, **kwargs):
... args = [int(x) for x in args]
... kwargs = dict((k, int(v)) for k, v in kwargs.items())
... return func(*args, **kwargs)
... return wrapper
...
>>> @args_as_ints
... def funny_function(x, y, z=3):
... """Computes x*y + 2*z"""
... return x*y + 2*z
...
>>> funny_function?
Type: function
String Form:<function funny_function at 0x7f17d5d4a620>
File: /usr/local/google/home/lodato/work/bcid/google3/security/bcid/<ipython-input-3-678cd3afed4b>
Definition: funny_function(*args, **kwargs)
Docstring: Computes x*y + 2*z
IPython 3.2.1:
>>> IPython.version_info
(3, 2, 1, '')
>>> funny_function?
Signature: funny_function(*args, **kwargs)
Docstring: Computes x*y + 2*z
File: ~/work/bcid/google3/security/bcid/<ipython-input-1-2c691e66224e>
Type: function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment