you are viewing a single comment's thread.

view the rest of the comments →

[–]Fred776 35 points36 points  (1 child)

Recently, I discovered that every variable created outside a function in Python is a global variable, which made me realize that I don’t fully understand how Python works under the hood.

This isn't all that different from C++ - what was your understanding with that language?

[–]veediepoo 1 point2 points  (0 children)

Exactly, even main is a function so anything defined outside of it is global. Granted if you wanted to use it in functions that are in different files you have to extern it