I'm using boto to manage some EC2 instances. It provides an Instance class. I'd like to subclass it to meet my particular needs. Since boto provides a query interface to get your instances, I need something to convert between classes. This solution seems to work, but changing the class attribute seems dodgy. Is there a better way?
from boto.ec2.instance import Instance as _Instance
class Instance(_Instance):
@classmethod
def from_instance(cls, instance):
instance.__class__ = cls
# set other attributes that this subclass cares about
return instance