2.2 open
Martin v. Loewis
martin at v.loewis.de
Sun Mar 24 17:12:40 EST 2002
Robin Becker <robin at jessikat.fsnet.co.uk> writes:
> 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 used to be a function that produces an open file, now it is a type
that produces an open file. Watch this:
>>> import httplib
>>> h=httplib.HTTP("localhost")
>>> print h
<httplib.HTTP instance at 0x816b85c>
So even though httplib.HTTP is a class (something that is very similar
to a type), you still can call it. Calling a type makes an instance of
the type.
> It's now not even amongst the built ins.
I don't understant this remark. open is certainly amongst the
built-ins:
>>> __builtins__.__dict__.has_key("open")
1
> what does X==type(X()) imply?
It implies that X is a type; calling a type gives an instance of the
type.
Regards,
Martin
More information about the Python-list
mailing list