Re: Type casting a base class to a derived one?

2007-01-24 Thread Cliff Wells
On Thu, 2007-01-11 at 08:41 -0600, Chris Mellon wrote: On 11 Jan 2007 15:01:48 +0100, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-01-11, Frederic Rentsch [EMAIL PROTECTED] wrote: If I derive a class from another one because I need a few extra features, is there a way to promote the base

Re: Type casting a base class to a derived one?

2007-01-24 Thread Chris Mellon
On 1/24/07, Cliff Wells [EMAIL PROTECTED] wrote: On Thu, 2007-01-11 at 08:41 -0600, Chris Mellon wrote: On 11 Jan 2007 15:01:48 +0100, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-01-11, Frederic Rentsch [EMAIL PROTECTED] wrote: If I derive a class from another one because I need a few

Re: Type casting a base class to a derived one?

2007-01-24 Thread Cliff Wells
On Wed, 2007-01-24 at 12:57 -0600, Chris Mellon wrote: In Python, you can do this simply by re-assigning the __class__. I'm not convinced that your type system makes sense, here though. Any reasonable ORM should be able to persist and reload an object without losing the type information.

Re: Type casting a base class to a derived one?

2007-01-24 Thread Cliff Wells
On Wed, 2007-01-24 at 11:37 -0800, Cliff Wells wrote: class Person: # assume this is something from the ORM name = Kenny class PersonRow ( Person ): pass def flatten_person ( p ): return spanomg, you've killed %p/span % p.name def flatten_personrow ( p ): return

Re: Type casting a base class to a derived one?

2007-01-24 Thread Chris Mellon
On 1/24/07, Cliff Wells [EMAIL PROTECTED] wrote: On Wed, 2007-01-24 at 12:57 -0600, Chris Mellon wrote: In Python, you can do this simply by re-assigning the __class__. I'm not convinced that your type system makes sense, here though. Any reasonable ORM should be able to persist and

Re: Type casting a base class to a derived one?

2007-01-15 Thread Frederic Rentsch
Chris Mellon wrote: On 11 Jan 2007 15:01:48 +0100, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-01-11, Frederic Rentsch [EMAIL PROTECTED] wrote: If I derive a class from another one because I need a few extra features, is there a way to promote the base class to the derived one

Type casting a base class to a derived one?

2007-01-11 Thread Frederic Rentsch
Hi all, If I derive a class from another one because I need a few extra features, is there a way to promote the base class to the derived one without having to make copies of all attributes? class Derived (Base): def __init__ (self, base_object): # ( copy all attributes ) ...

Re: Type casting a base class to a derived one?

2007-01-11 Thread bearophileHUGS
Frederic Rentsch: If I derive a class from another one because I need a few extra features, is there a way to promote the base class to the derived one without having to make copies of all attributes? class Derived (Base): def __init__ (self, base_object): # ( copy all

Re: Type casting a base class to a derived one?

2007-01-11 Thread Peter Otten
Frederic Rentsch wrote: If I derive a class from another one because I need a few extra features, is there a way to promote the base class to the derived one without having to make copies of all attributes? class Derived (Base): def __init__ (self, base_object): # ( copy all

Re: Type casting a base class to a derived one?

2007-01-11 Thread Neil Cerutti
On 2007-01-11, Frederic Rentsch [EMAIL PROTECTED] wrote: If I derive a class from another one because I need a few extra features, is there a way to promote the base class to the derived one without having to make copies of all attributes? class Derived (Base): def __init__ (self,

Re: Type casting a base class to a derived one?

2007-01-11 Thread Paul McGuire
Peter Otten [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Frederic Rentsch wrote: If I derive a class from another one because I need a few extra features, is there a way to promote the base class to the derived one without having to make copies of all attributes? class

Re: Type casting a base class to a derived one?

2007-01-11 Thread Chris Mellon
On 11 Jan 2007 15:01:48 +0100, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-01-11, Frederic Rentsch [EMAIL PROTECTED] wrote: If I derive a class from another one because I need a few extra features, is there a way to promote the base class to the derived one without having to make copies