What’s the scope of a variable initialized in an if statement?

I’m new to Python, so this is probably a simple scoping question. The following code in a Python file (module) is confusing me slightly: if __name__ == ‘__main__’: x = 1 print x In other languages I’ve worked in, this code would throw an exception, as the x variable is local to the if statement … Read more