[Tutor] class instance with identity crisis
Alan Gauld
alan.gauld at freenet.co.uk
Wed Jan 12 20:08:19 CET 2005
> My opinion is : this is a very dangerous and "stupid" thing to do
!!!
No its quite common. Its why C++ for example allows you to write
your own type convcersion functions! One area where I've used this
is to convert faults to orders in a service management application.
Its fairly common for a customer to report a fault which then turns
out to be due to a missing extra that theynneed to order. The
conversion function then copies all the captured order details
(cust ID and description etc) into a new fault object and returns
a reference to that.
> own type !!! Clearly, if you want to change the type of an object,
you
> want a conversion method (or function) and creates a new object
(that's
But this is true, changing the actual instance under the
covers is a bad idea.
> And last, I think you misunderstood the behaviour of the assignment
> statement in Python. In no way an assignement will overwrite an
existing
> value. It will ....
>
> I hope my last paragraph is clear (but I don't think so :D).
Well I understood it OK :-)
Alan G.
More information about the Tutor
mailing list