J. Clifford Dyer a écrit : > The code you just posted doesn't compile successfully. > > However, in your code, you probably have char_ptr defined at the > module level, and you're confused because you didn't declare it as > global. Am I right? My crystal ball has a smudge on it, but I think > I can still see okay. > > You can still reference module level variables that aren't declared > as global, but you can't assign to them. Or rather, when you try to, > you create a new local variable that shadows the global one. > > So the first time through, your char_ptr in the while expression is a > module level variable, but the second time through, it references a > local variable, because it has now been defined.
IIRC, local assignments are detected during compilation - so this is not how it works... -- http://mail.python.org/mailman/listinfo/python-list