A syntax question

Chris Angelico rosuav at gmail.com
Mon Nov 10 15:54:02 CET 2014


On Tue, Nov 11, 2014 at 1:35 AM, Joel Goldstick
<joel.goldstick at gmail.com> wrote:
> Your problem is that count is not local.  You are reading count from
> an outer scope.  When you try to increment count in your function, it
> can't because it doesn't exist.
> Don't use globals.

False analysis, I'm afraid. The problem is that the assignment will,
in the absence of a "global" declaration, cause the name "count" to
indicate a local variable - so it won't ever be read from outer scope.
However, the OP's issue is better solved by sharing tracebacks than by
us peering into crystal balls; mine's showing a very clear image at
the moment, but it might well be incorrect.

ChrisA



More information about the Python-list mailing list