2.2 open

Just van Rossum just at xs4all.nl
Sun Mar 24 12:48:19 EST 2002


In article <1UtsCLAcngn8EwWc at jessikat.fsnet.co.uk>,
 Robin Becker <robin at jessikat.fsnet.co.uk> wrote:

> >> So open is now a file? That seems a bit odd to me.
> >
> >Correction: open is the type of file.
> >
> >> It seems that some built ins now have the type of the object they
> >> create. Pretty weird logic.  
> >
> >Correction: some built ins are the type of the object they create.
> >
> >Notice that in 2.2 types and classes are unified.
> >
> yes I heard about that, but the semantics seem strange to me.
> open is not a file it is a function that produces an open file.

It still isn't a file (as Pearu tried to tell you), it's a factory for 
files. In 2.2 types are more like classes, in that calling a type object 
with the right arguments creates an object of that type.

> It's now
> not even amongst the built ins.
> 
> what does X==type(X()) imply?

It's more or less the same as

  X == X().__class__

(Also note that open is now an alias for the new "file" builtin, which 
considering how things now work is the more logical name. The builtin 
functions int, float and str (among others) are olso type objects these 
days.)

Just



More information about the Python-list mailing list