Be gentle with me....

Preston Landers prestonlanders at my-deja.com
Fri Dec 3 11:51:26 EST 1999


In article <828n3e$8kp$1 at nnrp1.deja.com>,
  ajmayo at my-deja.com wrote:

> 2. Does the debugger report context as in
>
> foo=bar + splat
>       ^  undeclared variable bar

By the way, I just reread your post, and though this is not the
question I was asking, you should understand that there isn't really a
concept of "undeclared variables" in Python.

Variables are 'declared' in a namespace when you first assign to them.
The tutorial section on namespaces contains some helpful pointers on
this subject.

For example:

>>> foo = 1
>>> foo = foo + bar
Traceback (innermost last):
  File "<stdin>", line 1, in ?
NameError: bar

This is probably what you meant, but I would just like to point out the
difference.  The problem here is not that bar is undeclared, since you
do not 'declare' variables like you do in C.  The NameError simply
means that Python tried to look up the name 'bar' in the namespace and
didn't find it.

Hope this clarifies,

---Preston

--
|| Preston Landers <prestonlanders at my-deja.com> ||


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list