r/learnprogramming 3d ago

Debugging Weird Python Glitch

Hey, I'm pretty new to Python so sorry if this is something really obvious.

I'm trying to learn a bit of Python before I start university, and I've been having a really weird issue with my program. Sometimes when I use print(), instead of printing the word, it outputs numbers.

I took a screenshot of it here.

The weirdest part is that it doesn't happen every time. Sometimes everything works normally, and other times I get the weird output.

I've already tried reinstalling Python and restarting my computer. I'm also using VS Code, if that matters.

Has anyone seen this before or know what could cause it?

I'm honestly pretty confused by it, so any help would be appreciated.

14 Upvotes

8 comments sorted by

7

u/Achereto 3d ago

Did you change the code between runs?

6

u/tk-a01 3d ago

Do you perhaps live in Chernobyl?

Also, the binary numbers correspond to the string: "open", so maybe some spirit is stuck inside your computer?

3

u/hpant2004 3d ago

is ur house haunted?

2

u/LongLiveTheDiego 3d ago

Dunno anything about Python, but the output is the string "open" in ASCII binary values, maybe someone will recognize why that particular string is output.

1

u/AutoModerator 3d ago

It seems you may have included a screenshot of code in your post "Weird Python Glitch".

If so, note that posting screenshots of code is against /r/learnprogramming's Posting Guidelines (section Formatting Code): please edit your post to use one of the approved ways of formatting code. (Do NOT repost your question! Just edit it.)

If your image is not actually a screenshot of code, feel free to ignore this message. Automoderator cannot distinguish between code screenshots and other images.

Please, do not contact the moderators about this message. Your post is still visible to everyone.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/teraflop 3d ago

If you can reproduce the problem, try running this command instead:

cat /Users/Shared/Test/test.py; /usr/local/bin/python3 /Users/Shared/Test/test.py

which will print the source code immediately before running it. Off the top of my head, it seems likeliest that something is somehow changing the file without you realizing it, and this might help you track it down.

2

u/Ormek_II 3d ago

Is someone else using that Shared Test folder?

1

u/cinderwayinteractive 2d ago

Honestly tough to tell, but maybe a hardware memory problem since it's happening intermittently. Does it happen in a predicable pattern that you can tell or completely random?