At 08:32 PM 6/11/2008 -0400, Terry Reedy wrote:
The Data Model chapter of the Reference Manual lists .__dict__ as a special
attribute of callables, modules, classes, and instances. It describes
__dict__ as a namespace dictionary or implementation of the namespace
thereof. Since namespaces map
At 02:59 AM 6/12/2008 +0200, Maciej Fijalkowski wrote:
It's about abusing locals, which are not even given that they'll
modify this dict.
Note that class bodies are a special case: as of PEP 3115, it's
possible for a class body's locals to be a non-dictionary object, so
it makes no sense to
Phillip J. Eby wrote:
At 08:32 PM 6/11/2008 -0400, Terry Reedy wrote:
The Data Model chapter of the Reference Manual lists .__dict__ as a
special
attribute of callables, modules, classes, and instances. It describes
__dict__ as a namespace dictionary or implementation of the namespace
At 01:34 PM 6/12/2008 +0200, Carl Friedrich Bolz wrote:
Phillip J. Eby wrote:
As it happens, most objects' __dict__ slots are settable by default, and
*require* that you set it to a dict or subclass thereof.
This is wrong for types:
Which is why I said most - to exclude types, and objects
Phillip J. Eby wrote:
At 01:34 PM 6/12/2008 +0200, Carl Friedrich Bolz wrote:
Phillip J. Eby wrote:
As it happens, most objects' __dict__ slots are settable by default,
and
*require* that you set it to a dict or subclass thereof.
This is wrong for types:
Which is why I said most - to
On Thu, Jun 12, 2008 at 2:56 PM, Carl Friedrich Bolz [EMAIL PROTECTED] wrote:
Of course attribute name lookups are affected, because you can have a
non-string key that has a __hash__ and __eq__ method to make it look
sufficiently like a string to the dict. Then the attribute lookup needs
to
Hi,
On Wed, Jun 11, 2008 at 10:44:17PM -0400, Scott Dial wrote:
The only reason the test used locals() was
because it was the only way to insert a non-string key into the class
namespace.
This discussion is mistakenly focused on locals(). There is a direct
way to have arbitrary keys in the
Phillip J. Eby [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| At 08:32 PM 6/11/2008 -0400, Terry Reedy wrote:
| The Data Model chapter of the Reference Manual lists .__dict__ as a
special
| attribute of callables, modules, classes, and instances. It describes
| __dict__ as a
On Thu, Jun 12, 2008 at 8:24 AM, Armin Rigo [EMAIL PROTECTED] wrote:
This discussion is mistakenly focused on locals(). There is a direct
way to have arbitrary keys in the dict of a type:
MyClass = type('MyClass', (Base,), {42: 64})
MyClass.__dict__[42]
64
There is, however, no way to
On Thu, Jun 12, 2008 at 9:46 PM, Guido van Rossum [EMAIL PROTECTED] wrote:
The intention was for these dicts to be used as namespaces. I think of
it as follows:
(a) Using non-string keys is a no-no, but the implementation isn't
required to go out of its way to forbid it.
That will allow
At 12:46 PM 6/12/2008 -0700, Guido van Rossum wrote:
The intention was for these dicts to be used as namespaces.
By these do you mean type object __dict__ attributes, or *all*
__dict__ attributes?
___
Python-Dev mailing list
Python-Dev@python.org
On Thu, Jun 12, 2008 at 1:01 PM, Willem Broekema [EMAIL PROTECTED] wrote:
On Thu, Jun 12, 2008 at 9:46 PM, Guido van Rossum [EMAIL PROTECTED] wrote:
The intention was for these dicts to be used as namespaces. I think of
it as follows:
(a) Using non-string keys is a no-no, but the
On Thu, Jun 12, 2008 at 2:42 PM, Phillip J. Eby [EMAIL PROTECTED] wrote:
At 12:46 PM 6/12/2008 -0700, Guido van Rossum wrote:
The intention was for these dicts to be used as namespaces.
By these do you mean type object __dict__ attributes, or *all* __dict__
attributes?
Hadn't thought of
On Wed, Jun 11, 2008 at 5:50 AM, Nick Coghlan [EMAIL PROTECTED] wrote:
Greg Ewing wrote:
Implementations are also permitted to restrict namespace dictionaries to
only accept string keys (I believe Jython does this for performance reasons
- CPython just optimised the hell out of normal
On Thu, Jun 12, 2008 at 8:19 PM, Frank Wierzbicki [EMAIL PROTECTED] wrote:
On Wed, Jun 11, 2008 at 5:50 AM, Nick Coghlan [EMAIL PROTECTED] wrote:
Greg Ewing wrote:
Implementations are also permitted to restrict namespace dictionaries to
only accept string keys (I believe Jython does this for
Greg Ewing wrote:
Maciej Fijalkowski wrote:
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working. Do we consider it part of python
language?
Modifying the dict returned by locals() is documented
as NOT being guaranteed to work, isn't it?
Yep - it
At 03:37 AM 6/11/2008 +0200, Maciej Fijalkowski wrote:
On Wed, Jun 11, 2008 at 3:36 AM, Scott Dial
[EMAIL PROTECTED] wrote:
Maciej Fijalkowski wrote:
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working.
I apologize for my ignorance, but who?
Phillip J. Eby wrote:
That test is there to ensure that it interoperates with code using the
AddOns library from the Cheeseshop; SQLAlchemy is not the source of the
usage.
Now that's interesting. The AddOns library uses class objects as keys in
the __dict__, but that doesn't says anything
Scott Dial [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
|| If non-string keys are not allowed in __dict__, then the AddOns library
| should be changed to add another dict to the object of interest to track
| these AddOn instances.
There are three possibilities with respect to
On Thu, Jun 12, 2008 at 2:32 AM, Terry Reedy [EMAIL PROTECTED] wrote:
Scott Dial [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
|| If non-string keys are not allowed in __dict__, then the AddOns library
| should be changed to add another dict to the object of interest to track
|
Maciej Fijalkowski [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Thu, Jun 12, 2008 at 2:32 AM, Terry Reedy [EMAIL PROTECTED] wrote:
|
| Scott Dial [EMAIL PROTECTED] wrote in message
| news:[EMAIL PROTECTED]
| || If non-string keys are not allowed in __dict__, then the AddOns
Maciej Fijalkowski wrote:
On Thu, Jun 12, 2008 at 2:32 AM, Terry Reedy [EMAIL PROTECTED] wrote:
Scott Dial [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
|| If non-string keys are not allowed in __dict__, then the AddOns library
| should be changed to add another dict to the object
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working. Do we consider it part of python
language? (Note that you cannot do the same with getattr/setattr which
checks if argument is a string)
Cheers,
fijal
___
On Tue, Jun 10, 2008 at 8:10 PM, Maciej Fijalkowski [EMAIL PROTECTED] wrote:
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working. Do we consider it part of python
language? (Note that you cannot do the same with getattr/setattr which
checks if
Benjamin Peterson wrote:
On Tue, Jun 10, 2008 at 8:10 PM, Maciej Fijalkowski [EMAIL PROTECTED] wrote:
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working. Do we consider it part of python
language? (Note that you cannot do the same with
Maciej Fijalkowski wrote:
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working.
I apologize for my ignorance, but who? Could you please cite something
reputable that relies on this detail?
--
Scott Dial
[EMAIL PROTECTED]
[EMAIL PROTECTED]
On Wed, Jun 11, 2008 at 3:36 AM, Scott Dial
[EMAIL PROTECTED] wrote:
Maciej Fijalkowski wrote:
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working.
I apologize for my ignorance, but who? Could you please cite something
reputable that relies on
On Tue, Jun 10, 2008 at 8:37 PM, Maciej Fijalkowski [EMAIL PROTECTED] wrote:
On Wed, Jun 11, 2008 at 3:36 AM, Scott Dial
I apologize for my ignorance, but who? Could you please cite something
reputable that relies on this detail?
It's in tests of sqlalchemy. My question is among the lines
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working. Do we consider it part of python
language? (Note that you cannot do the same with getattr/setattr which
checks if argument is a string)
Seems like a bug to me, but I don't think there is much we
On Tue, Jun 10, 2008 at 9:18 PM, Raymond Hettinger [EMAIL PROTECTED] wrote:
I see no reason to invent a new custom dict to prevent people from
doing something they find to be useful. If you can't segfault with it,
who cares.
Don't worry; I'm not suggesting it.
--
Cheers,
Benjamin Peterson
Maciej Fijalkowski wrote:
What do you think about this code:
class A:
locals()[42] = 98
Seems people rely on it working. Do we consider it part of python
language?
Modifying the dict returned by locals() is documented
as NOT being guaranteed to work, isn't it?
--
Greg
31 matches
Mail list logo