Does a function like isset() exist in Python?

Fredrik Lundh fredrik at pythonware.com
Thu Jun 23 03:47:57 EDT 2005


George Sakkis wrote:

> There are no unitialized variables in python; if you try to access an
> undefined  name, a NameError exception is raised:
>
> try:
>     print "foo is", foo
> except NameError:
>     print "foo is undefined"

note the order of evaluation:

    >>> try:
    ...     print "foo is", foo
    ... except NameError:
    ...     print "foo is undefined"
    ...
    foo is foo is undefined
    >>>

</F>






More information about the Python-list mailing list