[Tutor] one line code

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Tue Apr 5 15:07:12 CEST 2005



alan.gauld at freenet.co.uk a écrit :
>>This is a perfect opportunity to give the reminder that the
>>conversion 
>>functions are also types that can be used more transparently for such
> 
> 
> Neat I didn't know\ that. How dioes Python equate a function object
> to a type? Is it hard wired?

No, you see it the wrong way !
"int" is a type, not a function ! But, in Python, types append to be 
callable (ie. to behave like functions). For example when you define a 
class Foo with :

class Foo:
   def __init__(self):
     pass

Foo is a type but you can also *call* Foo with :

f = Foo()

But this construct an object (and involves many function calls) and is 
not a "simple" function call.
So there is no need to hardwire that kind of things (even if it _may_ be 
hardwired to improve efficiency).

-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68


More information about the Tutor mailing list