>> mydie = Die(mydie.n,5)
>>
>> And I believe you can do that by implementing the __coerce__
>> method. - but I've never tried it...
>
> If you can do that with __coerce__, I'm not clever enough to figure
> out
> how. IIRC, Python only calls __coerce__ if you're using arithmetic
> operators on dif
Carroll, Barry wrote:
> How do I overload the '=' operator to give the desired behavior?
This classic essay talks about the meaning of assignment in Python:
http://www.effbot.org/zone/python-objects.htm
Also I don't think there is any need to overload __lt__, etc.; just
__cmp__ is enough, it wil
On 9/20/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
> > This all seems to work okay.
> >
> > I want the assignment operator ('=')
>
> There is no assignment operator in Python, assignment is a
> binding of an object to a name.
as others have mentioned, the assignment operator is used to assign an
o
Alan Gauld wrote:
>> This all seems to work okay.
>>
>> I want the assignment operator ('=')
>
> There is no assignment operator in Python, assignment is a
> binding of an object to a name.
>
>> to call the
>> set method transparently on Die instances,
>> as in this fictitious example:
>
>
Carroll, Barry wrote:
> Greetings:
>
> I have a class that implements a die (singular or dice). Here is the class
> definition:
> How do I overload the '=' operator to give the desired behavior?
>
> Regards,
>
> Barry
AFAIK, you can't. Unlike, say, Java or C++, the assignment operator is
no
> This all seems to work okay.
>
> I want the assignment operator ('=')
There is no assignment operator in Python, assignment is a
binding of an object to a name.
> to call the
> set method transparently on Die instances,
> as in this fictitious example:
@BCARROLL[Python]|6> mydie = 5
@BCA
Greetings:
I have a class that implements a die (singular or dice). Here is the class
definition:
>>>
class Die(object):
"""Implements a gaming die.
Attributes:
n: the number of sides
Must correspond to the number of sides on a physical die.
val