On Nov 17, 7:11 am, Scott David Daniels wrote:
> Steve Howell wrote:
>
> ...
>
> > Eventually, I realized that it was easier to just monkeypatch Django
> > while I was in test mode to get a more direct hook into the behavior I
> > was trying to monitor, and then I didn't need to bother with
> > ov
Steve Howell wrote:
...
Eventually, I realized that it was easier to just monkeypatch Django
while I was in test mode to get a more direct hook into the behavior I
was trying to monitor, and then I didn't need to bother with
overriding __getitem__ or creating complicated wrapper objects
Sin
On Nov 16, 10:11 pm, Carl Banks wrote:
> On Nov 16, 10:32 am, Steve Howell wrote:
>
>
>
> > On Nov 16, 2:35 am, Carl Banks wrote:
>
> > > On Nov 15, 2:52 pm, Steve Howell wrote:
>
> > > > Does anybody have any links that points to the rationale for ignoring
> > > > instance definitions of __get
On Nov 16, 10:32 am, Steve Howell wrote:
> On Nov 16, 2:35 am, Carl Banks wrote:
>
>
>
> > On Nov 15, 2:52 pm, Steve Howell wrote:
>
> > > Does anybody have any links that points to the rationale for ignoring
> > > instance definitions of __getitem__ when new-style classes are
> > > involved? I
On Nov 16, 4:06 pm, greg wrote:
> Christian Heimes wrote:
> > Most magic methods are implemented as descriptors. Descriptors only
> > looked up on the type to increase the performance of the interpreter and
> > to simply the C API.
>
> There's also a semantic problem. Since new-style
> classes are
On Nov 16, 5:46 pm, Steven D'Aprano
wrote:
> On Mon, 16 Nov 2009 10:32:19 -0800, Steve Howell wrote:
> > Actually, the __getitem__ workaround that I proposed earlier only works
> > on subclasses of dict, not dict themselves. So given a pure dictionary
> > object, it is impossible to hook into att
On Mon, 16 Nov 2009 10:32:19 -0800, Steve Howell wrote:
> Actually, the __getitem__ workaround that I proposed earlier only works
> on subclasses of dict, not dict themselves. So given a pure dictionary
> object, it is impossible to hook into attribute lookups after
> instantiation in debugging/t
Christian Heimes wrote:
Most magic methods are implemented as descriptors. Descriptors only
looked up on the type to increase the performance of the interpreter and
to simply the C API.
There's also a semantic problem. Since new-style
classes are also instances (of class 'type') and you
can cr
On Nov 16, 2:35 am, Carl Banks wrote:
> On Nov 15, 2:52 pm, Steve Howell wrote:
>
> > Does anybody have any links that points to the rationale for ignoring
> > instance definitions of __getitem__ when new-style classes are
> > involved? I assume it has something to do with performance or
> > pro
On Nov 15, 2:52 pm, Steve Howell wrote:
> Does anybody have any links that points to the rationale for ignoring
> instance definitions of __getitem__ when new-style classes are
> involved? I assume it has something to do with performance or
> protecting us from our own mistakes?
"Not important
On Nov 15, 4:58 pm, Steve Howell wrote:
> On Nov 15, 4:03 pm, Christian Heimes wrote:
>
> > Try this untested code:
>
> > class Spam(dict):
> > def __getitem__(self, key):
> > getitem = self.__dict__.get("__getitem__", dict.__getitem__)
> > return getitem(self, key)
> > [...]
On Nov 15, 4:03 pm, Christian Heimes wrote:
> Steve Howell wrote:
> > Does anybody have any links that points to the rationale for ignoring
> > instance definitions of __getitem__ when new-style classes are
> > involved? I assume it has something to do with performance or
> > protecting us from o
Christian Heimes wrote:
Steve Howell wrote:
Does anybody have any links that points to the rationale for ignoring
instance definitions of __getitem__ when new-style classes are
involved? I assume it has something to do with performance or
protecting us from our own mistakes?
Most magic method
Steve Howell wrote:
> Does anybody have any links that points to the rationale for ignoring
> instance definitions of __getitem__ when new-style classes are
> involved? I assume it has something to do with performance or
> protecting us from our own mistakes?
Most magic methods are implemented as
On Nov 15, 12:01 pm, Jon Clements wrote:
> On Nov 15, 7:23 pm, Steve Howell wrote:
>
> > On Nov 15, 10:25 am, Steve Howell wrote:
>
> > > [see original post...]
> > > I am most
> > > interested in the specific mechanism for changing the __getitem__
> > > method for a subclass on a dictionary. T
On Nov 15, 12:01 pm, Jon Clements wrote:
> On Nov 15, 7:23 pm, Steve Howell wrote:
>
> > I am more precisely looking for a way to change the behavior of foo
> > ['bar'] (side effects and possibly return value) where "foo" is an
> > instance of a class that subclasses "dict," and where "foo" is no
On Nov 15, 7:23 pm, Steve Howell wrote:
> On Nov 15, 10:25 am, Steve Howell wrote:
>
> > [see original post...]
> > I am most
> > interested in the specific mechanism for changing the __getitem__
> > method for a subclass on a dictionary. Thanks in advance!
>
> Sorry for replying to myself, but
On Nov 15, 11:19 am, Gary Herron wrote:
> Steve Howell wrote:
> > I ran the following program, and found its output surprising in one
> > place:
>
> > class OnlyAl:
> > def __getitem__(self, key): return 'al'
>
> > class OnlyBob(dict):
> > def __getitem__(self, key): return
On Nov 15, 10:25 am, Steve Howell wrote:
> [see original post...]
> I am most
> interested in the specific mechanism for changing the __getitem__
> method for a subclass on a dictionary. Thanks in advance!
Sorry for replying to myself, but I just realized that the last
statement in my original p
Steve Howell wrote:
I ran the following program, and found its output surprising in one
place:
class OnlyAl:
def __getitem__(self, key): return 'al'
class OnlyBob(dict):
def __getitem__(self, key): return 'bob'
import sys; print sys.version
al = OnlyAl()
bo
I ran the following program, and found its output surprising in one
place:
class OnlyAl:
def __getitem__(self, key): return 'al'
class OnlyBob(dict):
def __getitem__(self, key): return 'bob'
import sys; print sys.version
al = OnlyAl()
bob = OnlyBob()
pri
21 matches
Mail list logo