[Python-3000] Types and classes (original) (raw)
Amaury Forgeot d'Arc amauryfa at gmail.com
Thu Apr 3 00:03:58 CEST 2008
- Previous message: [Python-3000] Types and classes
- Next message: [Python-3000] Types and classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
On Wed, Apr 2, 2008 at 11:57 PM, Paul Prescod <paul at prescod.net> wrote:
Apologies if this has been discussed before.
But does anyone else find it odd that the types of some things are classes and the classes of some things are types? >>> type(socket.socket()) <class 'socket.socket'> >>> type("abc") <type 'str'> >>> socket.socket().class <class 'socket.socket'> >>> "abc".class <type 'str'> In a recent talk I could only explain this as a historical quirk. As I understand, it is now possible to make types that behave basically exactly like classes and classes that behave exactly like types. Is there any important difference between them anymore?
I can find one difference:
- types are written in C
- classes are written in Python
and there is a difference in behaviour: most types don't have a writable dict, and you cannot add members. classes are more flexible.
-- Amaury Forgeot d'Arc
- Previous message: [Python-3000] Types and classes
- Next message: [Python-3000] Types and classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]