Saturday, January 15, 2005

"Monkey Typing" for Python

I've just posted a partial draft of a pre-PEP proposal to add what I'm calling "monkey typing" to Python. It's an extension of the infamous "duck typing" concept that seeks to simplify the use of interfaces in Python to the point where they scarcely exist, but are more useful than existing interface concepts for Python, including my own PyProtocols. In particular, it offers the first practical definition that I know of for a "file-like" object or a "dictionary-like" object. Check it out, then flame me for contributing to the impending ruin of the language you know and love! (Either here or on Python-Dev.)

(P.S. Since I know some of my readers are into that sort of thing, I'll mention that "monkey typing" is either an incredibly scaled-down version of Haskell typeclasses, or a extremely agile extension of Java casting or COM QueryInterface, depending on whether you prefer Haskell, Java, or C#. But if you don't like any of those languages, then pretend you didn't read this P.S. and just look at the proposal anyway, as it doesn't actually look anything at all like any of those languages, it just steals certain ideas from 'em.)