Understanding the scope of the variables in Python