"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
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)
>
>
"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
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
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