Re: Looking for assignement operator

2006-10-25 Thread Bruno Desthuilliers
Tommi wrote: > Bruno Desthuilliers wrote: > (about Traits) > >> How could it help ? > > To me they just looked a bit alike: > > --- op's example --- > a = MyInt(10) > # Here i need to overwrite the assignement operator > a = 12 > > --- traits' example --- > moe = Child() > # NOTIFICATION in act

Re: Looking for assignement operator

2006-10-20 Thread Tommi
Bruno Desthuilliers wrote: > (please don't top-post - corrected) (sorry) > How could it help ? To me they just looked a bit alike: --- op's example --- a = MyInt(10) # Here i need to overwrite the assignement operator a = 12 --- traits' example --- moe = Child() # NOTIFICATION in action moe

Re: Looking for assignement operator

2006-10-18 Thread Robert Kern
Bruno Desthuilliers wrote: > Tommi wrote: > (please don't top-post - corrected) >> >> Alexander Eisenhuth wrote: >>> Hello, >>> >>> is there a assignement operator, that i can overwrite? >>> >>> class MyInt: >>> def __init__(self, val): >>> assert(isinstance(val, int)) >>>

Re: Looking for assignement operator

2006-10-18 Thread Bruno Desthuilliers
Tommi wrote: (please don't top-post - corrected) > > > Alexander Eisenhuth wrote: >> Hello, >> >> is there a assignement operator, that i can overwrite? >> >> class MyInt: >> def __init__(self, val): >> assert(isinstance(val, int)) >> self._val = val >> >> a = MyInt

Re: Looking for assignement operator

2006-10-18 Thread Tommi
Could the "traits" package be of help? http://code.enthought.com/traits/ Alexander Eisenhuth wrote: > Hello, > > is there a assignement operator, that i can overwrite? > > class MyInt: > def __init__(self, val): > assert(isinstance(val, int)) > self._val = val

Re: Looking for assignement operator

2006-10-17 Thread Bruno Desthuilliers
Jerry wrote: > Okay, very well, then I put a couple of extra 'self' identifiers in > there when I hand-copied the code over. You should try copy/paste - it's both safer and less work !-) > That would be my mistake for > letting my fingers do the walking and forgetting my brain. Is there > anyth

Re: Looking for assignement operator

2006-10-17 Thread Jerry
Okay, very well, then I put a couple of extra 'self' identifiers in there when I hand-copied the code over. That would be my mistake for letting my fingers do the walking and forgetting my brain. Is there anything else wrong with my code? -- Jerry -- http://mail.python.org/mailman/listinfo/pyt

Re: Looking for assignement operator

2006-10-17 Thread Bruno Desthuilliers
Jerry wrote: >> class MyClass:Descriptors don't work fine with old-style classes. > Interesting, I have used this construct before in Python 2.4.3 and not > run into the recursion problem you talk about. The recursion problem doesn't occur with you original code (for the good reason that there's a

Re: Looking for assignement operator

2006-10-17 Thread Jerry
> class MyClass:Descriptors don't work fine with old-style classes. Interesting, I have used this construct before in Python 2.4.3 and not run into the recursion problem you talk about. Also, it has worked fine for me. Perhaps you can post a link to your source so that I could study it and unders

Re: Looking for assignement operator

2006-10-17 Thread Alexander Eisenhuth
Wow, thanks a lot for your quick answers. That assignement is no operator, but a statemant is a pity, but indeed I came foward with overwritten methods for numeric types Regards Alexander -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for assignement operator

2006-10-17 Thread Bruno Desthuilliers
Jerry wrote: (snip) > I believe the property function is what you are looking for. It is not. > e.g. > > class MyClass: Descriptors don't work fine with old-style classes. Should be: class MyClass(object): > def __init__(self, val): > self.setval(val) > > def getval(self): >

Re: Looking for assignement operator

2006-10-17 Thread Bruno Desthuilliers
Steven D'Aprano wrote: > On Tue, 17 Oct 2006 15:50:47 +0200, Alexander Eisenhuth wrote: > >> Hello, >> >> is there a assignement operator, that i can overwrite? > > No. > > We were just discussing the reasons why Python will not and can not have > an assignment operator just a few days ago. Chec

Re: Looking for assignement operator

2006-10-17 Thread Jerry
On Oct 17, 8:50 am, Alexander Eisenhuth <[EMAIL PROTECTED]> wrote: > Hello, > > is there a assignement operator, that i can overwrite? > > class MyInt: > def __init__(self, val): > assert(isinstance(val, int)) > self._val = val > > a = MyInt(10) > > # Here

Re: Looking for assignement operator

2006-10-17 Thread Steven D'Aprano
On Tue, 17 Oct 2006 15:50:47 +0200, Alexander Eisenhuth wrote: > Hello, > > is there a assignement operator, that i can overwrite? No. We were just discussing the reasons why Python will not and can not have an assignment operator just a few days ago. Check the archives for more details. > cl

Re: Looking for assignement operator

2006-10-17 Thread Laurent Pointal
Alexander Eisenhuth a écrit : > Hello, > > is there a assignement operator, that i can overwrite? Adding to Simon Brunning reply (assignment is a statement). > class MyInt: > def __init__(self, val): > assert(isinstance(val, int)) > self._val = val > > a = MyInt(10) > > # H

Re: Looking for assignement operator

2006-10-17 Thread Rob Wolfe
Alexander Eisenhuth wrote: > Hello, > > is there a assignement operator, that i can overwrite? You can't overwrite assignment operator, but you can overwrite methods of numeric objects: http://docs.python.org/ref/numeric-types.html HTH, Rob -- http://mail.python.org/mailman/listinfo/python-li

Re: Looking for assignement operator

2006-10-17 Thread Fredrik Lundh
Alexander Eisenhuth wrote: > is there a assignement operator, that i can overwrite? no. -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for assignement operator

2006-10-17 Thread Simon Brunning
On 10/17/06, Alexander Eisenhuth <[EMAIL PROTECTED]> wrote: > Hello, > > is there a assignement operator, that i can overwrite? Soirry, no, assignment is a statement, not an operator, and can't be overridden. -- Cheers, Simon B [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http

Looking for assignement operator

2006-10-17 Thread Alexander Eisenhuth
Hello, is there a assignement operator, that i can overwrite? class MyInt: def __init__(self, val): assert(isinstance(val, int)) self._val = val a = MyInt(10) # Here i need to overwrite the assignement operator a = 12 Thanks Alexander -- http://mail.py