[Python-Dev] PEP for Better Control of Nested Lexical Scopes (original) (raw)
Samuele Pedroni pedronis at strakt.com
Wed Feb 22 22:27:51 CET 2006
- Previous message: [Python-Dev] PEP for Better Control of Nested Lexical Scopes
- Next message: [Python-Dev] PEP for Better Control of Nested Lexical Scopes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Almann T. Goo wrote:
As far as I remember, Guido wasn't particularly opposed to the idea, but the discussion fizzled out after having failed to reach a consensus on an obviously right way to go about it.
My apologies for bringing this debated topic again to the front-lines--that said, I think there has been good, constructive things said again and sometimes it doesn't hurt to kick up an old topic. After pouring through some of the list archive threads and reading through this thread, it seems clear to me that the community doesn't seem all that keen on fixing issue--which was my goal to ferret out. For me this is one of those things where the Pythonic thing to do is not so clear--and that mysterious, enigmatic definition of what it means to be Pythonic can be quite individual so I definitely don't want to waste my time arguing what that means. The most compelling argument for not doing anything about it is that the use cases are probably not that many--that in itself makes me less apt to push much harder--especially since my pragmatic side agrees with a lot of what has been said to this regard. IMO, Having properly nested scopes in Python in a sense made having closures a natural idiom to the language and part of its "user interface." By not allowing the name re-binding it almost seems like that "user interface" has a rough edge that is almost too easy to get cut on. This in-elegance seems very un-Pythonic to me.
If you are looking for rough edges about nested scopes in Python this is probably worse:
x = [] for i in range(10): ... x.append(lambda : i) ... [y() for y in x] [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]
although experienced people can live with it. The fact is that importing nested scope from the like of Scheme it was not considered that in Scheme for example, looping constructs introduce new scopes. So this work more as expected there. There were long threads about this at some point too.
Idioms and features mostly never port straightforwardly from language to language.
For example Python has nothing with the explicit context introduction and grouping of a Scheme 'let', so is arguable that nested scope code, especially with rebindings, would be less clear, readable than in Scheme (tastes in parenthesis kept aside).
Anyhow, good discussion.
Cheers, Almann -- Almann T. Goo almann.goo at gmail.com
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/pedronis%40strakt.com
- Previous message: [Python-Dev] PEP for Better Control of Nested Lexical Scopes
- Next message: [Python-Dev] PEP for Better Control of Nested Lexical Scopes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]