Am Tuesday 11 May 2010 11:38:42 schrieb Ulrich Eckhardt: > Richard Lamboj wrote: > > "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. > > I'd suggest the tutorial, see http://docs.python.org, though your question > is already beyond the range of beginners' questions. > > > 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'> > > The expression "10.5" will always be a float, you can't change that. What > > you can do is create your own type, derived from float: > >>> class myfloat(float): > > ... pass > ... > > and then create an object of that type: > >>> x = myfloat(3.14) > >>> type(x) > > <class '__main__.myfloat'> > > > > Lastly one warning: In many cases where people wanted to derive from a > concrete data type, their problems were easier solved by external code. I > don't know your problem though. > > Uli > > -- > Sator Laser GmbH > Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
I just want to test what is possible with python and what not. There is no problem that i need to solve. This is what i'am searching for: http://docs.python.org/reference/datamodel.html Last year i have stopped programming python, but now i'am back with a big black hole in my brain and i want to understand what the interpreter is doing in the background. I think my question was not well formulated... Kind Regards -- http://mail.python.org/mailman/listinfo/python-list