-
Notifications
You must be signed in to change notification settings - Fork 956
New issue
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
SOURCE IS UNAVAILABLE #230
Comments
I'm guessing you didn't put the code in the file, but rather in some shell. I'm guessing that shell isn't IPython. Which shell is it? |
I run the script on win10 python 3.11.0 |
I get the same output when using Jupyterlab. from functools import reduce
import pysnooper
@pysnooper.snoop()
def multi(x,y):
return x*y
print(reduce(multi,range(1,4)))
multi(5,2) Output
|
Calling just regular python repl from the command prompt:
|
@Sionwage Thanks for reporting. It would be good to be able to get the source in these cases, but I probably won't work on this because it's not important enough for me. If you're interested feel free to dig in and implement it. |
Ok, I think I found why I get the source is unavailable for me. I was running this with Jupyterlab in a cell. If I move the function to a '.py' file like 'test.py' with this code: import pysnooper
@pysnooper.snoop()
def adder(x, y):
answer = x + y
return answer
if __name__ == '__main__':
print(adder(5, 20)) and call the function from Jupyterlab by running this: import test
test.adder(5, 20) I get this output that matches the functionality outlined in the readme:
I think that this cannot be used with its full functionality in Jupyterlab or Ipython unless there is an actual source file for PySnooper to scrape from? |
I guess so. It's possible it could be implemented, but you'll need to roll up your sleeves for that. |
I'm just tickled I got this working as it is very handy. This is probably my cue to get out of Jupyter and start using a more mature workflow. |
Hi, I tried the demo but get SOURCE IS UNAVAILABLE instead of code line in output. Any idea how to fix this? Thanks
【code】
import pysnooper
@pysnooper.snoop()
def number_to_bits(number):
if number:
bits = []
while number:
number, remainder = divmod(number, 2)
bits.insert(0, remainder)
return bits
else:
return [0]
number_to_bits(6)
【output】
Source path:... /tmp/ipykernel_114851/428676888.py
Starting var:.. number = 6
11:57:49.141100 call 3 SOURCE IS UNAVAILABLE
11:57:49.141751 line 5 SOURCE IS UNAVAILABLE
11:57:49.141791 line 6 SOURCE IS UNAVAILABLE
New var:....... bits = []
11:57:49.141826 line 7 SOURCE IS UNAVAILABLE
11:57:49.141883 line 8 SOURCE IS UNAVAILABLE
Modified var:.. number = 3
New var:....... remainder = 0
11:57:49.141916 line 9 SOURCE IS UNAVAILABLE
Modified var:.. bits = [0]
11:57:49.141975 line 7 SOURCE IS UNAVAILABLE
11:57:49.142021 line 8 SOURCE IS UNAVAILABLE
Modified var:.. number = 1
Modified var:.. remainder = 1
11:57:49.142054 line 9 SOURCE IS UNAVAILABLE
Modified var:.. bits = [1, 0]
11:57:49.142108 line 7 SOURCE IS UNAVAILABLE
11:57:49.142153 line 8 SOURCE IS UNAVAILABLE
Modified var:.. number = 0
11:57:49.142183 line 9 SOURCE IS UNAVAILABLE
Modified var:.. bits = [1, 1, 0]
11:57:49.142226 line 7 SOURCE IS UNAVAILABLE
11:57:49.142268 line 10 SOURCE IS UNAVAILABLE
11:57:49.142299 return 10 SOURCE IS UNAVAILABLE
Return value:.. [1, 1, 0]
The text was updated successfully, but these errors were encountered: