Python Scoping: Run it over me one more time please...

Moshe Zadka moshez at
Sat Mar 25 11:10:59 CET 2000

On Fri, 24 Mar 2000, Warren Postma wrote:

> # so how do I create a function that increments a global and returns it!?

Use the (surprise!) "global" keyword:

z = 1
def inc_z():
	global z
	z = z+1
	return z

Moshe Zadka <mzadka at>. -- we put the penguin in .com

More information about the Python-list mailing list