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
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
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))
>>>
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
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
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
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
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
> 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
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
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):
>
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
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
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
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
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
Alexander Eisenhuth wrote:
> is there a assignement operator, that i can overwrite?
no.
--
http://mail.python.org/mailman/listinfo/python-list
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
18 matches
Mail list logo