Nice way to cast a homogeneous tuple

Ulrich Eckhardt eckhardt at satorlaser.com
Wed Jul 28 09:58:29 EDT 2010


wheres pythonmonks wrote:
> Thanks ... I thought int was a type-cast (like in C++) so I assumed I
> couldn't reference it.

Hopefully somebody correct me if I explain this badly, but I'll take a
shot...


Firstly, "int" is a class. Python doesn't make a distinction between builtin
types and class types like C++, where you e.g. can't derive from builtin
types.

Secondly, the class is callable like a function. When called, it creates an
instance of that class. Therefore, when you create an object it has a
similar syntax as when calling a function.

Lastly, classes are not special. Like any variable or function they can be
referenced by a name or by multiple names, and thus be passed as parameters
to a function.

Cheers!

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932




More information about the Python-list mailing list