Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Ethan Furman
Nick Coghlan wrote: On Thu, Mar 8, 2012 at 11:42 AM, Benjamin Peterson benja...@python.org wrote: 2012/3/7 Victor Stinner victor.stin...@gmail.com: Can't we simply raise an error if the dict contains non-string keys? Sounds okay to me. For 3.3, the most we can do is trigger a deprecation

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Lennart Regebro
On Thu, Mar 8, 2012 at 08:46, Ethan Furman et...@stoneleaf.us wrote: I think it would be sad to lose that functionality. If we are going to, though, we may as well check the string to make sure it's a valid identifier: That would break even more code. I have encountered many cases of

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Guido van Rossum
On Thu, Mar 8, 2012 at 1:10 AM, Lennart Regebro rege...@gmail.com wrote: On Thu, Mar 8, 2012 at 08:46, Ethan Furman et...@stoneleaf.us wrote: I think it would be sad to lose that functionality. If we are going to, though, we may as well check the string to make sure it's a valid identifier:

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Ethan Furman
Guido van Rossum wrote: On Wed, Mar 7, 2012 at 11:43 PM, Ethan Furman wrote: Are you able to modify classes after class creation in Python 3? Without using a metaclass? Yes, by assignment to attributes. The __dict__ is a read-only proxy, but attribute assignment is allowed. (This is because

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Guido van Rossum
On Thu, Mar 8, 2012 at 8:22 AM, Ethan Furman et...@stoneleaf.us wrote: Guido van Rossum wrote: On Wed, Mar 7, 2012 at 11:43 PM, Ethan Furman wrote: Are you able to modify classes after class creation in Python 3? Without using a metaclass? Yes, by assignment to attributes. The __dict__ is

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread PJ Eby
On Thu, Mar 8, 2012 at 2:43 AM, Ethan Furman et...@stoneleaf.us wrote: PJ Eby wrote: Short version: AddOns are things you can use to dynamically extend instances -- a bit like the decorator in decorator pattern (not to be confused with Python decorators). Rather than synthesize a unique

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread fwierzbi...@gmail.com
On Wed, Mar 7, 2012 at 5:39 PM, Victor Stinner victor.stin...@gmail.com wrote: Hi, During the Language Summit 2011 (*), it was discussed that PyPy and Jython don't support non-string key in type dict. An issue was open to emit a warning on such dict, but the patch has not been commited yet.

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Ethan Furman
Guido van Rossum wrote: On Thu, Mar 8, 2012 at 8:22 AM, Ethan Furman et...@stoneleaf.us wrote: Guido van Rossum wrote: On Wed, Mar 7, 2012 at 11:43 PM, Ethan Furman wrote: Are you able to modify classes after class creation in Python 3? Without using a metaclass? Yes, by assignment to

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Amaury Forgeot d'Arc
Hi, 2012/3/8 Ethan Furman et...@stoneleaf.us: A little more experimentation shows that not all is well, however: -- dir(Test) Traceback (most recent call last):  File stdin, line 1, in module TypeError: unorderable types: int() str() So what conclusion do you draw? That other changes

[Python-Dev] Non-string keys in type dict

2012-03-07 Thread Victor Stinner
Hi, During the Language Summit 2011 (*), it was discussed that PyPy and Jython don't support non-string key in type dict. An issue was open to emit a warning on such dict, but the patch has not been commited yet. I'm trying to Lib/test/crashers/losing_mro_ref.py: I wrote a patch fixing the

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Benjamin Peterson
2012/3/7 Victor Stinner victor.stin...@gmail.com: So my question is: what is the use case of such dict? Why do we still support it? Probably a side-effect of implementation. Can't we simply raise an error if the dict contains non-string keys? Sounds okay to me. -- Regards, Benjamin

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Victor Stinner
During the Language Summit 2011 (*), it was discussed that PyPy and Jython don't support non-string key in type dict. An issue was open to emit a warning on such dict, but the patch has not been commited yet. It's the issue #11455. As written in the issue, there are two ways to create such

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Chris Kaynor
On Wed, Mar 7, 2012 at 5:45 PM, Victor Stinner victor.stin...@gmail.comwrote: During the Language Summit 2011 (*), it was discussed that PyPy and Jython don't support non-string key in type dict. An issue was open to emit a warning on such dict, but the patch has not been commited yet.

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Brett Wilkins
I see that I've misunderstood this entirely, nevermind me. --Brett On 08/03/12 14:48, Brett Wilkins wrote: I assume when you say non-string keys this includes numbers. But in Pypy, I can certainly use numbers: {'1':1, 1:2}.keys() ['1', 1] I can even use a lambda (obviously not a string, a

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Brett Wilkins
I assume when you say non-string keys this includes numbers. But in Pypy, I can certainly use numbers: {'1':1, 1:2}.keys() ['1', 1] I can even use a lambda (obviously not a string, a number, nor what I would consider a primitive): {'1':1, (lambda x: x):2}.keys() ['1', function lambda at

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Nick Coghlan
On Thu, Mar 8, 2012 at 11:42 AM, Benjamin Peterson benja...@python.org wrote: 2012/3/7 Victor Stinner victor.stin...@gmail.com: Can't we simply raise an error if the dict contains non-string keys? Sounds okay to me. For 3.3, the most we can do is trigger a deprecation warning, since removing

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Steven D'Aprano
On Thu, Mar 08, 2012 at 12:20:21PM +1000, Nick Coghlan wrote: On Thu, Mar 8, 2012 at 11:42 AM, Benjamin Peterson benja...@python.org wrote: 2012/3/7 Victor Stinner victor.stin...@gmail.com: Can't we simply raise an error if the dict contains non-string keys? Sounds okay to me. For

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread PJ Eby
On Wed, Mar 7, 2012 at 8:39 PM, Victor Stinner victor.stin...@gmail.comwrote: So my question is: what is the use case of such dict? Well, I use them for this: http://pypi.python.org/pypi/AddOns (And I have various other libraries that depend on that library.) Short version: AddOns are

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Maciej Fijalkowski
On Wed, Mar 7, 2012 at 5:42 PM, Benjamin Peterson benja...@python.org wrote: 2012/3/7 Victor Stinner victor.stin...@gmail.com: So my question is: what is the use case of such dict? Why do we still support it? Probably a side-effect of implementation. Can't we simply raise an error if the

Re: [Python-Dev] Non-string keys in type dict

2012-03-07 Thread Ethan Furman
PJ Eby wrote: Short version: AddOns are things you can use to dynamically extend instances -- a bit like the decorator in decorator pattern (not to be confused with Python decorators). Rather than synthesize a unique string as a dictionary key, I just used the AddOn classes themselves as