We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
>>> from varname import argname >>> from functools import singledispatch >>> >>> @singledispatch ... def add(a, b): ... ... ... >>> @add.register(int) ... def _(a, b): ... aname = argname(a, b) ... print(aname) ... return a + b ... >>> def mul(a, b): ... aname = argname(a, b) ... print(aname) ... return a * b ... >>> x = y = 1 >>> >>> mul(x, y) ('x', 'y') 1 >>> >>> add(x, y) Traceback (most recent call last): File "<input>", line 1, in <module> add(x, y) File "/.../lib/python3.7/functools.py", line 840, in wrappe r return dispatch(args[0].__class__)(*args, **kw) File "<input>", line 3, in _ aname = argname(a, b) File "/.../varname/core.py", line 401, in argnam e f"No value passed for argument {argnode.id!r}, " ValueError: No value passed for argument 'a', or it is not an argument at all.
The text was updated successfully, but these errors were encountered:
@2d94eff
>>> from varname import argname >>> from functools import singledispatch >>> >>> @singledispatch ... def add(a, b): ... ... ... >>> @add.register(int) ... def add_int(a, b): ... aname = argname(a, b, func=add_int) ... print(aname) ... return a + b ... >>> @add.register(str) ... def add_str(a, b): ... aname = argname(a, b, dispatch=str) # specify a type ... print(aname) ... return a + b ... >>> x = y = 1 >>> p = q = 'a' >>> >>> add(x, y) ('x', 'y') 2 >>> add(p, q) ('p', 'q') 'aa'
Sorry, something went wrong.
Close via v0.7.0
pwwang
No branches or pull requests
The text was updated successfully, but these errors were encountered: