inherit from data type

Richard Lamboj richard.lamboj at bilcom.at
Tue May 11 05:18:54 EDT 2010


Am Tuesday 11 May 2010 10:47:35 schrieb Ulrich Eckhardt:
> Richard Lamboj wrote:
> > i want to inherit from a data type. How can i do this? Can anyone explain
> > more abou this?
>
> Other than in e.g. C++ where int and float are special types, you can
> inherit from them in Python like from any other type. The only speciality
> of int, float and string is that they are immutable.
>
> > How knows python that it is a float, or a string?
>
> I'm not actually sure I understand this question. If you derive from float,
> Python obviously knows that you derive from float....
>
>
> Uli
>
> --
> Sator Laser GmbH
> Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

"How knows python that it is a float, or a string?" Sorry this was bad 
expressed. I want to create a new data type, which inherits from float. I 
just know the "dir" function and the "help" function to get more infromations 
about the class, but i need to get more information about the class 
structure.

What i also want to know:
>>> variable1 = 10.50
>>> type(variable1)
<type 'float'>

Is there a way to tell python that it use antoher class than float for float, 
like myfloat? Its just a "tell-me-what-is-possible".

Sample:
>>> variable1 = 10.50
>>> type(variable1)
<type 'myfloat'>

Kind Regards,

Richi



More information about the Python-list mailing list