namespaces & indentation
Chris Schaller
Chris.Schaller at web.de
Fri Dec 22 15:56:04 EST 2000
More information about the Python-list mailing list
Fri Dec 22 15:56:04 EST 2000
- Previous message (by thread): namespaces & indentation
- Next message (by thread): namespaces & indentation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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...
- 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