bow = Ribbon(colour='yellow') tie(bow, old_oak_tree) for archer in troop: let bow = get_weapon() archer.take(bow) assert bow.colour = 'yellow'
I had just this problem yesterday, and on many other days. However, I don't think the opt-in block scoping would have done much to help.
In my particular case, I had some geographic data in a file. It seemed like a name like 'geo_data' was a good way to refer to the filename with the data. Then it seemed like 'geo_data was a good way to refer to the file handle. Then it seemed like a name like 'geo_data' was a good way to refer to the DataFrame resulting from reading it. Then it seemed like 'geo_data' was a good way to refer to the reformatted data I created in memory. Then it seemed like 'geo_data' was a good name for the file handle to the new file I write in the new format.
Naming things is hard. (I might have exaggerated the specific example).
But not much of the problem had to do with scoping. I pretty much wanted to use all those different meanings in the same scope. And also not use absurdly long names like 'filehandle_for_json_geo_data'. Even if scoping *could* have separated all those uses, it would be kinda terrible code where that same name had all these different meanings nearby, even if in technically different scopes.