[Python-ideas] A different kind of context manager

Kristján Valur Jónsson kristjan at ccpgames.com
Thu Oct 24 12:36:02 CEST 2013



> -----Original Message-----
> From: Python-ideas [mailto:python-ideas-
> bounces+kristjan=ccpgames.com at python.org] On Behalf Of Masklinn
> Sent: 23. október 2013 15:17
> To: python-ideas ideas
> Subject: Re: [Python-ideas] A different kind of context manager
> > (CS buffs out there will likely point out to me that this was not an original
> Matz invention).
> 
> You don't need CS buffs to point it out, it was an implementation detail
> leaking into semantic incompatibility between types implemented in C and
> classes implemented in Python:
> http://python-history.blogspot.be/2010/06/new-style-classes.html
> 
> Python was fairly unique in having this dichotomy between built-in and user-
> defined types[0].
> 
> [0] but not anymore, Go has repeated this mistake, amongst others.

That's not what I was referring to, rather the class model that blew my mind when learing Ruby back in 2000.  I'm not a CS, so this was new to me (knowing OOP only from C++):
- Classes, metaclasses, methor resolution order.
- All classes are subclasses of "object"
- object itself is an instance of "type",  type being a "metaclass".
- type, too, is a subclass of object.  Type is its own metaclass, so "type" is an instance of "type".

Ruby was designed with this model in mind, it only arrived later into Python.

K



More information about the Python-ideas mailing list