Re: [Python-3000] Change to class construction?

2007-07-09 Thread Ron Adam
Phillip J. Eby wrote: > At 07:40 PM 7/9/2007 -0500, Ron Adam wrote: > >> Guido van Rossum wrote: >> >>> We could easily change this to return a >>> writable mapping that's not a dict at all but a "view" on the locals >>> just as dict.keys() returns a view on a dict. I don't see why locals() >>>

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Fred L. Drake, Jr.
On Monday 09 July 2007, Greg Ewing wrote: > Isn't it rather dangerous to rely on any built-in > Python operations to be atomic? They might happen > to be, but I don't think there's any guarantee > they will stay that way. My limited recollection is that setdefault() was all about it being atom

Re: [Python-3000] Announcing PEP 3136

2007-07-09 Thread Greg Ewing
Matt Chisholm wrote: > Are break / continue currently abused more than they are used right, > or used to make code difficult to understand? In my experience, using break and continue for anything other than a standard loop-and-a-half makes code hard to follow, even when there is only one loop. Lab

Re: [Python-3000] Announcing PEP 3136

2007-07-09 Thread Matt Chisholm
On Jul 3 2007, 10:14, Guido van Rossum wrote: >On 6/30/07, Matt Chisholm <[EMAIL PROTECTED]> wrote: >>I've created and submitted a new PEP proposing support for labels in >>Python's break and continue statements. Georg Brandl has graciously >>added it to the PEP list as PEP 3136: >> >>http://www.

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Greg Ewing
Phillip J. Eby wrote: > However, there is another class of use cases which use setdefault for > its limited atomic properties - the initialization of non-mutated > data structures that are shared among threads. Isn't it rather dangerous to rely on any built-in Python operations to be atomic? The

Re: [Python-3000] Change to class construction?

2007-07-09 Thread Phillip J. Eby
At 07:40 PM 7/9/2007 -0500, Ron Adam wrote: >Guido van Rossum wrote: > >>We could easily change this to return a >>writable mapping that's not a dict at all but a "view" on the locals >>just as dict.keys() returns a view on a dict. I don't see why locals() >>couldn't return the object used to repr

Re: [Python-3000] Change to class construction?

2007-07-09 Thread Ron Adam
Guido van Rossum wrote: > We could easily change this to return a > writable mapping that's not a dict at all but a "view" on the locals > just as dict.keys() returns a view on a dict. I don't see why locals() > couldn't return the object used to represent the namespace, but I > don't see that it

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Ron Adam
Barry Warsaw wrote: > However, .setdefault() is a horrible name because it's not clear from > the name that a 'get' operation also happens. The return value of .setdefault() could be changed to None, then the name would be correct. And then a helper function could fill the current use case of

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Phillip J. Eby
At 12:04 AM 7/10/2007 +0300, Guido van Rossum wrote: >On 7/9/07, Barry Warsaw <[EMAIL PROTECTED]> wrote: >>Phillip, I support any initiative to keep .setdefault() or similar >>functionality. When this thread came up before, I wasn't against >>defaultdict, I just didn't think it covered enough of t

Re: [Python-3000] Change to class construction?

2007-07-09 Thread Phillip J. Eby
At 11:56 PM 7/9/2007 +0300, Guido van Rossum wrote: > The use of the word "mapping" >might easily be construed as implementing abc.Mapping, and then >iteration and reading the contents would be well-defined. I'm not sure which use of the word "mapping" you're talking about. PEP 3115 is explicit

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Jul 9, 2007, at 5:29 PM, Raymond Hettinger wrote: >> PEP 3100 suggests dict.setdefault() may be removed in Python 3, since >> it is in principle no longer necessary (due to the new defaultdict >> type). > > I've forgotten. What was the whole poi

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Jul 9, 2007, at 5:04 PM, Guido van Rossum wrote: > On 7/9/07, Barry Warsaw <[EMAIL PROTECTED]> wrote: >> Phillip, I support any initiative to keep .setdefault() or similar >> functionality. When this thread came up before, I wasn't against >> defa

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Robert Brewer
Raymond Hettinger wrote: > > PEP 3100 suggests dict.setdefault() may be removed in > > Python 3, since it is in principle no longer necessary > > (due to the new defaultdict type). > > I've forgotten. What was the whole point of Python 3.0? > Is it to make the language fat with lots of ways to d

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Raymond Hettinger
> PEP 3100 suggests dict.setdefault() may be removed in Python 3, since > it is in principle no longer necessary (due to the new defaultdict type). I've forgotten. What was the whole point of Python 3.0? Is it to make the language fat with lots of ways to do everything? Guys, this is your ONE ch

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Guido van Rossum
On 7/9/07, Barry Warsaw <[EMAIL PROTECTED]> wrote: > Phillip, I support any initiative to keep .setdefault() or similar > functionality. When this thread came up before, I wasn't against > defaultdict, I just didn't think it covered enough of the use cases > of .setdefault() to warrant its removal

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Brandon Craig Rhodes
Barry Warsaw <[EMAIL PROTECTED]> writes: > However, .setdefault() is a horrible name because it's not clear > from the name that a 'get' operation also happens. Agreed! From the name, a clever but naive user would assume that "setdefault" sets what value the dictionary returns when a key does no

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Guido van Rossum
On 7/9/07, tav <[EMAIL PROTECTED]> wrote: > setdefault's ability to return current value is also a very useful > functionality and has saved writing: > > if key not in dict: > value = > dict[key] = value > > with the simpler: > > value = dict.setdefault(key, ) > > Is there a better way

Re: [Python-3000] Change to class construction?

2007-07-09 Thread Guido van Rossum
On 7/9/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > At 06:13 PM 7/9/2007 +0300, Guido van Rossum wrote: > >On 7/9/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > > At 09:03 PM 7/9/2007 +1000, Nick Coghlan wrote: > > > >However, I will point out that setting class attributes via locals() is > >

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Jul 9, 2007, at 2:44 PM, Phillip J. Eby wrote: > PEP 3100 suggests dict.setdefault() may be removed in Python 3, since > it is in principle no longer necessary (due to the new defaultdict > type). > > However, there is another class of use cases

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Phillip J. Eby
At 07:59 PM 7/9/2007 +0100, tav wrote: >>PEP 3100 suggests dict.setdefault() may be removed in Python 3, since >>it is in principle no longer necessary (due to the new defaultdict type). >> >>However, there is another class of use cases which use setdefault for >>its limited atomic properties - the

Re: [Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread tav
> PEP 3100 suggests dict.setdefault() may be removed in Python 3, since > it is in principle no longer necessary (due to the new defaultdict type). > > However, there is another class of use cases which use setdefault for > its limited atomic properties - the initialization of non-mutated > data st

[Python-3000] A request to keep dict.setdefault() in 3.0

2007-07-09 Thread Phillip J. Eby
PEP 3100 suggests dict.setdefault() may be removed in Python 3, since it is in principle no longer necessary (due to the new defaultdict type). However, there is another class of use cases which use setdefault for its limited atomic properties - the initialization of non-mutated data structures

Re: [Python-3000] Change to class construction?

2007-07-09 Thread Phillip J. Eby
At 06:13 PM 7/9/2007 +0300, Guido van Rossum wrote: >On 7/9/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > At 09:03 PM 7/9/2007 +1000, Nick Coghlan wrote: > > >However, I will point out that setting class attributes via locals() is > > >formally undefined (it happens to work in current versions

Re: [Python-3000] Change to class construction?

2007-07-09 Thread Guido van Rossum
On 7/9/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > At 09:03 PM 7/9/2007 +1000, Nick Coghlan wrote: > >However, I will point out that setting class attributes via locals() is > >formally undefined (it happens to work in current versions of CPython, > >but there's no guarantee that will always be

Re: [Python-3000] Change to class construction?

2007-07-09 Thread Phillip J. Eby
At 09:03 PM 7/9/2007 +1000, Nick Coghlan wrote: >However, I will point out that setting class attributes via locals() is >formally undefined (it happens to work in current versions of CPython, >but there's no guarantee that will always be the case). As of PEP 3115, it's no longer undefined for cla

Re: [Python-3000] Change to class construction?

2007-07-09 Thread Nick Coghlan
Brian Harring wrote: > > I'd be curious if there is anyway to preserve the existing behaviour; > > class foo: > some_list = ('blacklist1', 'blacklist2') > known_bad = some_list += ('blah',) > locals().update([(attr, some_callable) for attr in some_list]) > > is slightly contrived, but I u