Re: Variable name has a typo, but code still works. Why?
- From: Max M <maxm@xxxxxx>
- Date: Wed, 31 May 2006 16:27:40 +0200
mateus wrote:
print "hello world"
I have a nested loop where the outer loop iterates over key value pairs
of a dictionary and the inner loop iterates over a list each list of
which is a mapped value from the dictionary
def showReport(self):
for dev, sessions in self.logger.items():
for tree in session:
self.addTestItem(self, tree)
What I don't understand is why this executes w/o any problems when
"sessions" was spelled as plural (sessionS) while later being spelled
in the singular (session).
Is there some type of name resolution of local variables where Python
makes assumptions?
No. You are probably running your script in an ide that keeps an old variable hanging around.
Try it from a command promt.
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
Phone: +45 66 11 84 94
Mobile: +45 29 93 42 96
.
- References:
- Variable name has a typo, but code still works. Why?
- From: mateus
- Variable name has a typo, but code still works. Why?
- Prev by Date: Re: iterator? way of generating all possible combinations?
- Next by Date: Re: iterator? way of generating all possible combinations?
- Previous by thread: Re: Variable name has a typo, but code still works. Why?
- Next by thread: Re: Variable name has a typo, but code still works. Why?
- Index(es):
Relevant Pages
|