Wrapping classes

Colin J. Williams cjw at sympatico.ca
Fri Sep 23 14:43:59 CEST 2005


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 idea. :-) )
> 
> 
> What I'd like to do precisely is to be able to evaluate an expression like
> "a+2*b" (using eval) where a and b are objects which behave like numarray
> arrays, but whose values aren't computed until their used.
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(..).

Colin W.
> 
> I need to compute the values when used because the arrays could depend on
> each other, and the easiest way to get the evaluation order correct is to
> only evaluate them when they're used.
> 
> An alternative way is to do some string processing to replace a with
> computearray("a") in the expression or something horrible like that.
> 
> Thanks
> 
> Jeremy
> 



More information about the Python-list mailing list