namespaces & indentation
matt
matt at virtualspectator.com
Fri Dec 22 18:06:27 EST 2000
More information about the Python-list mailing list
Fri Dec 22 18:06:27 EST 2000
- Previous message (by thread): namespaces & indentation
- Next message (by thread): namespaces & indentation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
that is perfectly normal ... this might help you http://python.sourceforge.net/peps/pep-0227.html On Sat, 23 Dec 2000, Chris Schaller wrote: > Dear Pythoners... > > I always thought that I understood Python's scoping, but then I came across > that code: > > def t(x): > > if x == 1: > > c = 'yeah' > > return c > > If I execute t(1), I'll get 'yeah', but otherwise there'll be an error > message. According to the indentation level c is only valid within the > if-clause, but not on the outside. So I guess, the indentation level only > defines the lines of code that belong to the if-clause, but has nothing to do > with scopes. > > That's very confusing, I've already programmed a lot in Python, but only > due to a program error (I forgot to initialize c at the beginning of the > function - a common error) and an unsuccessful test this happened to a program > after months of error-free running. > > Any comments? > > bye > Chris... > -- > http://www.python.org/mailman/listinfo/python-list -- Matt Halstead (PhD) Research and development VirtualSpectator http://www.virtualspectator.com ph 64-9-9136896
- Previous message (by thread): namespaces & indentation
- Next message (by thread): namespaces & indentation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list