Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> They are not ambiguous if you have the whole file in your head.

They're not ambiguous period, python's `=` always performs a local declaration unless overridden via the keywords you mentioned.

> This is why there are keywords like "global" & "nonlocal".

It's the exact opposite of your statement: `global` and `nonlocal` indicate non-local bindings, because by default all bindings are local and you do not need to have "the whole file in your head".



Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: