Ian Bicking: the old part of his blog

Comment

Hmmm... so *you're* the reason Guido's uncomfortable with how far people might take adaptation. ;)

The v.__class__ example is... I hate to say wrong, but actually it is. If you have an object that's a type already, you'd get back the same object. So, adapting an object to its type doesn't make sense.

In general, I don't think you can make a slots -> interface mapping of the sort you've laid out. I'd be more likely to say that certain slots or combinations could be described by interfaces, and that Python uses the slot presence rather than an adaptation mechanism to find them.

It's true that slots like __int__, __str__, and __nonzero__ are for type conversion, and therefore could be treated in terms of adaptation, though.

And the traversal stuff is also too far out there... *why* would you use that style, when it's so much harder to read?

Ah well, people are going to experiment with this sort of thing in their "wild youth", but hopefully they'll settle down into the "adaptation as type-casting" model where it best fits. :)
Comment on Adaptation vs. Magic Methods
by Phillip J. Eby