David Bolen db3l at
Thu Oct 25 01:02:02 CEST 2001

"Larry Whitley" <ldw at> writes:

> That's it!  Here's the offending code, a little earlier in process().
>         elif pc.command == "dual": # command was a dual address cycle
>             pc.command, None, None = tr.decodeCommand()
> Looks like it considers None a variable though it is not under the elif that
> used it.

Yes, local variable determination is a static compile-time operation,
based on compiling an assignment, and not runtime based.  But the
error is runtime based if the variable gets used in the code path
before being initialized.

There's no clean way to ignore components in tuple unpacking, but you
definitely want to avoid using existing names (such as None), since
while it's just a name binding to the builtin None object, most code
works better when "None" really points to that object :-)

If you don't want to create a throwaway name, or don't want to keep a
reference to the other tuple elements around, you could always change
that line to something like:

    pc.command = tr.decodeCommand()[0]

-- David
 \               David Bolen            \   E-mail: db3l at  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \

More information about the Python-list mailing list