Talin wrote: >Ka-Ping Yee wrote: > > >>On Mon, 10 Jul 2006 [EMAIL PROTECTED] wrote: >> >> >> >>>I think Talin's got a point though. It seems hard to find one short English >>>word that captures the essence of the desired behavior. None of the words >>>in his list seem strongly suggestive of the meaning to me. I suspect that >>>means one's ultimately as good (or as bad) as the rest. >>> >>> >>What's wrong with "nonlocal"? I don't think i've seen an argument >>against that one so far (from Talin or others). >> >> > >Well, I just think that a fix for "an aesthetic wart" should be, well, >aesthetic :) > >I also think that it won't be a complete disaster if we do nothing at >all - there *are* existing ways to deal with this problem; there are >even some which aren't hackish and non-obvious. For example, its easy >enough to create an object which acts as an artificial scope: > > def x(): > scope = object() > scope.x = 1 > def y(): > scope.x = 2 > >To my mind, the above code looks about as elegant and efficient as most >of the proposals put forward so far, and it already works. > >How much are we really saving here by building this feature into the >language? > > >>> def x(): ...: scope = object() ...: scope.x = 1 ...: def y(): ...: scope.x = 2 >>> x() --------------------------------------------------------------------------- exceptions.AttributeError Traceback (most recent call last)<ipython console>
I've often found it a nuisance that you can't instantiate an 'object', to use as a mutable 'namespace', but instead have to define an arbitrary empty class. What happened to the 'namespace' proposal ? Michael Foord http://www.voidspace.org.uk/python/index.shtml >-- Talin >_______________________________________________ >Python-Dev mailing list >Python-Dev@python.org >http://mail.python.org/mailman/listinfo/python-dev >Unsubscribe: >http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk > > > _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com