Re: Converting between objects

2007-07-20 Thread Alex Popescu
"Nathan Harmston" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi, > > I have being thinking about this and was wondering with built in types > you can do things like > > float(1) or str(200) > > is there way I can define conversion functions like this: > > say i have a class A and

Re: Converting between objects

2007-07-20 Thread Bruno Desthuilliers
Nathan Harmston a écrit : > Hi, > > I have being thinking about this and was wondering with built in types > you can do things like > > float(1) or str(200) > > is there way I can define conversion functions like this: > > say i have a class A and a class B > > bobj = B() > aobj = a(bobj) > >

Re: Converting between objects

2007-07-19 Thread Ben Finney
"Nathan Harmston" <[EMAIL PROTECTED]> writes: > I have being thinking about this and was wondering with built in types > you can do things like > > float(1) Calls the constructor for the 'float' type, passing the integer 1; the constructor returns a new float object. > str(200) Calls the const

Re: Converting between objects

2007-07-19 Thread Bjoern Schliessmann
Nathan Harmston wrote: > is there way I can define conversion functions like this: > > say i have a class A and a class B > > bobj = B() > aobj = a(bobj) > > in a neater way than just defining a set of methods > > def a(object_to_convert) > # if object_to_convert of type.. > # do s

Converting between objects

2007-07-19 Thread Nathan Harmston
Hi, I have being thinking about this and was wondering with built in types you can do things like float(1) or str(200) is there way I can define conversion functions like this: say i have a class A and a class B bobj = B() aobj = a(bobj) in a neater way than just defining a set of methods de