Walter Dörwald wrote: > This looks strange to me. In all other cases of variable lookup the global > variable z would be found.
The next case assigns to z, making z local to whereis. This is consistent with python's existing scoping rules (for example, try rewriting this as the equivalent if-elif chain and you'll get the same error). It sounds like you want to add "global z" to the top of the function definition. > whereis(23) however works. This branch is hit before the unbound local lookup is attempted. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/CZAZYFSWWEYTXDEXEZ75TNTVKSIZZ27K/ Code of Conduct: http://python.org/psf/codeofconduct/