On Sat, 31 May 2008 12:48:41 am Armin Ronacher wrote:
Greg Ewing <greg.ewing <at> canterbury.ac.nz> writes:
Well, I'm skeptical about the whole ABC thing in the first place -- it all seems very unpythonic to me.
I think it's very pythonic and the very best solution to interfaces *and* duck typing. Not only does it extend duck-typing in a very, very cool way
I'm with Greg on this one: despite the assertions made in the PEP, I don't see how ABC can fail to be anything but anti-duck-typing. How does it extend duck-typing? Can you give an example?
but also does it provide a very cool way to get custom sets or lists going with few extra work. Subclassing builtins was always very painful in the past
"Always" very painful? class ListWithClear(list): def clear(self): self[:] = self.__class__() Not so very painful to me. Maybe I just have more pain-tolerance than some people.
and many used the User* objects which however often broke because some code did something like isinstance(x, (tuple, list)). Of course one could argue that instance checking is the root of all evil
Perhaps not the root of *all* evil but it is certainly the root of much evil, and the treatment of delegation-based classes like UserString as second-class objects is a good example of why isinstance checking should be avoided as much as possible. -- Steven