A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/066821.html below:

[Python-Dev] 2.5 and beyond

[Python-Dev] 2.5 and beyond [Python-Dev] 2.5 and beyondAndrew Koenig ark at acm.org
Fri Jun 30 18:30:28 CEST 2006
> The question is, what behaviour is preferable for this code:
> 
>     g = 1
>     def f():
>         g += 1
> 
>     f()
> 
> Should this raise an UnboundLocalError or should it increment g?

I think it should increment (i.e. rebind) g, for the same reason that

	g = [1]
	def f():
		g[0] += 1
	f()

rebinds g[0].



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4