Jason Doege wrote:
> Thanks for the good and useful information on this. Now for the why...
> 
> I am building an API and for various reasons I have chosen Python to
> implement it. I'd like to separate the implementation from the interface
> as, for instance, C++ does with separate .hpp and .cpp files. Apart from
> defining a class with a bunch of empty methods and then redefining them,
> I have not seen a good way to do this in Python. Can you recommend the
> Pythonic way to do this?

For smaller projects don't bother. For large projects Zope Interface 
seems to be popular: http://wiki.zope.org/Interfaces/FrontPage

PyProtocols is similar but no longer actively developed: 
http://peak.telecommunity.com/PyProtocols.html

A different approach, perhaps more Pythonic, is for consumers to check 
what kind of thing they are given. One way to do this is here:
http://oakwinter.com/code/typecheck/

You might also be interested in
http://www.python.org/dev/peps/pep-0246/
http://www.python.org/dev/peps/pep-3107/

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to