python-varname
python-varname copied to clipboard
VarnameRetrievingError: Cannot retrieve the node where the function is called.
If you see this warning and the errors caused by it, please ensure you are running your code in the environment where the source code is available at runtime.
Typical environment where the source code is not available at runtime:
- Raw Python REPL (type
pythonfrom command line and run your code there) -
exec()
If you want to use a Python REPL to run your code, ipython, bpython and jupyter notebook are recommended.
If you can't avoid using exec(), use exec_code() from varname.helpers instead.
What if I want to use exec() anyway? The idea is to tell exec where to retrieve the source code. See how exec_code() is implemented:
https://github.com/pwwang/python-varname/blob/ea1ec82fa608d13cb6d44f849b9df3c6a7c90501/varname/helpers.py#L229-L297
Related:
- https://github.com/pwwang/python-varname/issues?q=is%3Aissue+is%3Aclosed+label%3AREPL