You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't think this would be the right result for pfile. You can run this on standard library without any problem, e.g. %pfile telnetlib. The issue pfile has with math is not that it is a standard library, but rather that it cannot find the python source code file the module points to, since it's a compiled binary. There's no source file - hence "No file found".
I think it could be helpful to point users towards the standard library in such cases, regardless of their setup.
Also, I don't really understand the mechanics of %pfile. I created a file test.py in the current directory with the contents specific_var = 5, then executed from test import specific_var and then %pfile specific_var. I expected it to point me towards file.py, but it also printed out No file found for specific_var.
I disagree. It would be very difficult to tell whether something is actually stdlib or not, you'd have to maintain a list throughout each platform × python version, which would be a nightmare'ish endeavour.
I expected it to point me towards file.py, but it also printed out No file found for specific_var.
As I understand it, you're giving it the value 5, which is not defined anywhere where %pfile can look. The docs say:
Print (or run through pager) the source code for an object.
5 is not defined in your file, and you cannot get its source code by using Python's introspection tools, hence No file found for specific_var.
Steps to reproduce
import math
%pfile math
%pfile math.log
Expected result
Both calls to
%pfile
tell the user thatmath
is a part of the standard libraryActual result
Both calls to
%pfile
produce an error:System info
Manjaro Linux, Python 3.9.4, IPython 7.22.0 (reproduces on IPython 8.0.0.dev)
The text was updated successfully, but these errors were encountered: