Curious case of UnboundLocalError

Johannes Bauer dfnsonfsduifb at gmx.de
Sat Mar 31 05:37:28 EDT 2018


On 30.03.2018 16:46, Ben Bacarisse wrote:

>> Yup, but why? I mean, at the point of definition of "z", the only
>> definition of "collections" that would be visible to the code would be
>> the globally imported module, would it not? How can the code know of the
>> local declaration that only comes *after*?
> 
> Why questions can be hard.  The language definition says what's supposed
> to happen.  Is that enough of an answer to why?

Absolutely. Don't get me wrong, I dont't doubt either the correctness of
your answer nor question the design choice. I just found it surprising
and cool.

Thanks for clearing it up.

Cheers,
Joe



-- 
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
 - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1 at speranza.aioe.org>



More information about the Python-list mailing list