On 14 Dec 2006 13:57:10 -0800, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:
Hi,
I'm having problems wrapping a hierarchy of classes, actually having
problems wrapping the base class. I don't need to use the WrapClass
mechanism since I don't want to override classes in Python. My code
boils down
[EMAIL PROTECTED] wrote:
> Chris Lambacher wrote:
> > On Thu, Dec 14, 2006 at 01:57:10PM -0800, [EMAIL PROTECTED] wrote:
> > > Hi,
> > > I'm having problems wrapping a hierarchy of classes, actually having
> > > problems wrapping the base class. I don't need to use the WrapClass
> > > mechanism sin
Chris Lambacher wrote:
> On Thu, Dec 14, 2006 at 01:57:10PM -0800, [EMAIL PROTECTED] wrote:
> > Hi,
> > I'm having problems wrapping a hierarchy of classes, actually having
> > problems wrapping the base class. I don't need to use the WrapClass
> > mechanism since I don't want to override classes
On Thu, Dec 14, 2006 at 01:57:10PM -0800, [EMAIL PROTECTED] wrote:
> Hi,
> I'm having problems wrapping a hierarchy of classes, actually having
> problems wrapping the base class. I don't need to use the WrapClass
> mechanism since I don't want to override classes in Python. My code
> boils down to
Hi,
I'm having problems wrapping a hierarchy of classes, actually having
problems wrapping the base class. I don't need to use the WrapClass
mechanism since I don't want to override classes in Python. My code
boils down to:
class Base
{
public:
virtual ~Base()
{}
virtual v
Jeremy Sanders wrote:
> Colin J. Williams wrote:
>
>
>>Could you not have functions a and b each of which returns a NumArray
>>instance?
>>
>>Your expression would then be something like a(..)+2*b(..).
>
>
> The user enters the expression (yes - I'm aware of the possible security
> issues), as
I agree this is a case for using metaclasses. What about an
implementation like this ? Seems like checking if init was already
called will slow down all attribute access significantly, but, I don't
like this approach of changing the __init__ method.
class LazyInit(type):
def __new__(self, n
Colin J. Williams wrote:
> Could you not have functions a and b each of which returns a NumArray
> instance?
>
> Your expression would then be something like a(..)+2*b(..).
The user enters the expression (yes - I'm aware of the possible security
issues), as it is a scientific application. I don'
Jeremy Sanders wrote:
> Peter Hansen wrote:
>
>
>>Almost anything is possible in Python, though whether the underlying
>>design idea is sound is a completely different question. (Translation:
>>try the following pseudo-code, but I have my suspicions about whether
>>what you're doing is a good i
bruno modulix wrote:
> Could it work with a UserDict subclass ?
Unfortunately not:
Traceback (most recent call last):
File "test.py", line 17, in ?
print eval("10 * a + b", globals(), l)
TypeError: eval() argument 3 must be dict, not instance
Thanks
Jeremy
--
Jeremy Sanders
http://www.
Jeremy Sanders wrote:
> Diez B. Roggisch wrote:
>
>
>>It works - in python 2.4!! I tried subclassing dict, but my
>>__getitem__-method wasn't called - most probably because it's a C-type,
>>but I don't know for sure. Maybe someone can elaborate on that?
>
>
> Yes - I tried that (see thread belo
Diez B. Roggisch wrote:
> It works - in python 2.4!! I tried subclassing dict, but my
> __getitem__-method wasn't called - most probably because it's a C-type,
> but I don't know for sure. Maybe someone can elaborate on that?
Yes - I tried that (see thread below). Unfortunately it needs Python 2.
Jeremy Sanders wrote:
> Peter Hansen wrote:
>
>
>>Almost anything is possible in Python, though whether the underlying
>>design idea is sound is a completely different question. (Translation:
>>try the following pseudo-code, but I have my suspicions about whether
>>what you're doing is a good i
Peter Hansen wrote:
> Almost anything is possible in Python, though whether the underlying
> design idea is sound is a completely different question. (Translation:
> try the following pseudo-code, but I have my suspicions about whether
> what you're doing is a good idea. :-) )
What I'd like to
Paolino wrote:
> class NotInitializedObjects(type):
> def __init__(cls,*_):
> realInit=cls.__init__
> def __newInit__(self,*pos,**key):
> def _init():
> realInit(self,*pos,**key)
> self._init=_init
> cls.__init__=__newInit__
> def __getattribute__(self,attr):
Jeremy Sanders wrote:
> Is it possible to implement some sort of "lazy" creation of objects only
> when the object is used, but behaving in the same way as the object?
Smells like a Proxy pattern...
> For instance:
>
> class Foo:
> def __init__(self, val):
> """This is really slow."""
>
Jeremy Sanders wrote:
> Is it possible to implement some sort of "lazy" creation of objects only
> when the object is used, but behaving in the same way as the object?
>
A generic approach would override __getattribute__ to let it perform the
__init__ method on not initialized objects.This is a
Jeremy Sanders wrote:
> Is it possible to implement some sort of "lazy" creation of objects only
> when the object is used, but behaving in the same way as the object?
>
> For instance:
>
> class Foo:
> def __init__(self, val):
> """This is really slow."""
> self.num = val
>
> # this d
Is it possible to implement some sort of "lazy" creation of objects only
when the object is used, but behaving in the same way as the object?
For instance:
class Foo:
def __init__(self, val):
"""This is really slow."""
self.num = val
# this doesn't call Foo.__init__ yet
a = lazyclass(F
19 matches
Mail list logo