PEP 3119 ABC - And how I learned to love the Abstract Bomb

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Thu May 13 08:30:50 EDT 2010


In message <mailman.90.1273639153.32709.python-list at python.org>, Hatem 
Nassrat wrote:

> 1. To create a YajlContentHandler class that forces all sub-classers
> to implement a certain set of methods. (Great, thats what ABC is for)
> 
> 2. Conditional Abstractness! if certain methods are not implemented
> then be able to require some method to be implemented.

You’re looking at it wrong. If you want to force people to do things in a 
certain way, use Java. Python is about enabling things, not forcing them.

Don’t use subclassing. Instead, let the caller pass you a duck-typed object 
that implements the methods you need.



More information about the Python-list mailing list