Ah, I see -- this is a really good point, thanks for bringing it up. You're right, one can not arbitrarily increase scope in Python. The most common way I've seen of demarcating this kind of structure is actually using a blank line. For example, the code would instead look more like:
c = create_context()
for foo in foos:
do_something(foo, c)
do_other_thing(foo, c)
accumulate(foos, c)
do_other_stuff
One could also throw the separate stuff into a new function.
Re:Lisp vs Python
by neutronicus on Sunday February 20, 2011 @07:34PM
(#2243674)
One could also throw the separate stuff into a new function.
That's the elephant in the room in all of these "my language is more readable" discussions, isn't it?
The code I wrote does this (because c is 1 indentation level deeper than the main_scope functions). I do not know if it is legal Python to simply increase indentation level to demarcate a new scope, but I suspect it is not, and it is certainly not common practice.
This is really a minor gripe - but then again so are the article's - it's pretty easy to tell a binding from a function call.