[Edu-sig] Properties use case

Arthur ajsiegel at optonline.net
Sat Mar 18 23:48:11 CET 2006


 

> >-----Original Message-----
> >From: edu-sig-bounces at python.org 
> >[mailto:edu-sig-bounces at python.org] On Behalf Of Michael Tobis
> >objects than values.
> >
> >So, is there a problem with wrapping them thus:
> >
> >###
> >class mcx(object):
> >
> >  def  __init__(self,val):
> >     self.val = complex(val)
> >
> >  def __add__(self,other):
> >      """ and similarly for most other special methods """
> >     return self.val.__add__(other)

 >###
> >
> >I think Arthur would duckishly call this a mutable complex 
> >type and others would more formally call it an object 
> >containing a reference to an immutable complex type and we 
> >could all live happily ever after. 


Not so easy, I'm afraid.  If I am understanding correctly the implementation
that you are suggesting is exactly the one I had one generation ago.  Kind
of the UserArray solution.  No?

And I can't easily explain why I felt the need to push it a step further -
to in fact having a more truly full implementation of complex numerics
contained *as* my object - not as an attribute of it.  But there were
reasons.  Some more practical, more less.

Art





More information about the Edu-sig mailing list