Mega Code Archive

 
Categories / Python Tutorial / Function
 

The global Statement

# Global names are names at the top level of the enclosing module file. # Global names must be declared only if they are assigned in a function. # Global names may be referenced in a function without being declared. X = 88  def func(  ):     global X     X = 99                     # Global X: outside def func(  ) print X                        # Prints 99