My opinion is : this is a very dangerous and stupid thing to do !!!
Try to imagine the complexity of your program for someone who is trying
to understand how your code is working if an object suddenly change its
own type !!! Clearly, if you want to change the type of an object, you
want a
A couple of ideas:
You could have dry() return the new weapon:
def dry(self):
return Prune()
then the client code would be
weapon = weapon.dry()
You could have the weapon encapsulate another object and delegate to it.
Finally, you actually can change the class of an object just by assigning
On Wednesday 12 January 2005 12:10, Kent Johnson wrote:
A couple of ideas:
You could have dry() return the new weapon:
def dry(self):
return Prune()
then the client code would be
weapon = weapon.dry()
You could have the weapon encapsulate another object and delegate to it.
As
On Wed, 12 Jan 2005, Barnaby Scott wrote:
I was wondering how you can get an instance of a class to change itself
into something else (given certain circumstances), but doing so from
within a method. So:
class Damson:
def __str__(self):
return 'damson'
def dry(self):
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
! Thanks
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Alan Gauld
Sent: 12 January 2005 20:13
To: Alan Gauld; Barnaby Scott; 'Tutor'
Subject: Re: [Tutor] class instance with identity crisis
Whoops, I forgot to do an assignment