Skip to content
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

No variable output from the last line #237

Open
webber26232 opened this issue May 18, 2023 · 3 comments
Open

No variable output from the last line #237

webber26232 opened this issue May 18, 2023 · 3 comments

Comments

@webber26232
Copy link

webber26232 commented May 18, 2023

Hi, I found that the variable, new or modified, in the last line will not be shown. Below is the same example with the print removed:

import pysnooper
import random

def foo():
    lst = []
    for i in range(10):
        lst.append(random.randrange(1, 1000))

    with pysnooper.snoop():
        lower = min(lst)
        upper = max(lst)
        mid = (lower + upper) / 2

foo()

which outputs something like:

New var:....... lst = [379, 800, 331, 57, 210, 524, 525, 837, 118, 810]
New var:....... i = 9
22:46:58.874665 line        10         lower = min(lst)
New var:....... lower = 57
22:46:58.876660 line        11         upper = max(lst)
New var:....... upper = 837
22:46:58.876660 line        12         mid = (lower + upper) / 2
Elapsed time: 00:00:00.003000

We can find that the variable mid was not printed. Please let me know if this is expected.

@webber26232 webber26232 changed the title No variable output for the last line No variable output from the last line May 18, 2023
@cool-RR
Copy link
Owner

cool-RR commented May 18, 2023

It is not expected. However, it doesn't reproduce for me:

Source path:... C:\Users\Administrator\Desktop\ass.py
New var:....... lst = [615, 725, 892, 822, 832, 521, 9, 195, 356, 904]
New var:....... i = 9
12:29:32.836714 line        10         lower = min(lst)
New var:....... lower = 9
12:29:32.836714 line        11         upper = max(lst)
New var:....... upper = 904
12:29:32.836714 line        12         mid = (lower + upper) / 2
New var:....... mid = 456.5
12:29:32.836714 line         9     with pysnooper.snoop():
Elapsed time: 00:00:00.000999

I'm on Python 3.10.10 on Windows 10 and PySnooper==1.1.1. What about you?

@webber26232
Copy link
Author

My env is Python 3.9.13 on Windows 10 and PySnooper==1.1.1

@cool-RR
Copy link
Owner

cool-RR commented May 19, 2023

I see. This is indeed a bug but too low priority for me to work on. If you or anyone else want to try to understand what's happening and fix it, go ahead. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants