Re: Variable name has a typo, but code still works. Why?
- From: "Tim N. van der Leeuw" <tim.leeuwvander@xxxxxxxxxxxxx>
- Date: 31 May 2006 06:55:59 -0700
Hi Mateus,
We'd need to see more code then just this snippet. It looks like the
name 'session' is used elsewhere in the code, and is in scope for the
showReport() method.
But without seeing a bit more code of this class, and possibly global
variables / code, it's not possible to say this.
There's definately no rules in Python that allow you to 'abbreviate'
variable names.
Cheers,
--Tim
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?
.
- 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: Variable name has a typo, but code still works. Why?
- 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
|
Loading