[Python-Dev] 2.5 and beyond (original) (raw)
Andrew Koenig ark at acm.org
Fri Jun 30 18:30:28 CEST 2006
- Previous message: [Python-Dev] 2.5 and beyond
- Next message: [Python-Dev] 2.5 and beyond
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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].
- Previous message: [Python-Dev] 2.5 and beyond
- Next message: [Python-Dev] 2.5 and beyond
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]