Python "implements <interface>" equivalent?
Sion Arrowsmith
siona at chiark.greenend.org.uk
Fri Oct 5 06:54:30 EDT 2007
Grant Edwards <grante at visi.com> wrote:
> try:
> myobj.feature1()
> except AttributeError:
> print "object doesn't implement feature1"
>
>isn't correct, since an unhandled AttributeError generated by
>the feature1 method will print "object doesn't implement
>feature1".
I'd be tempted to argue that it *was* correct, since the object
doesn't implement a feature1 which can be used. (This is the cue
for someone to talk about making sure that myobj's class has
been thoroughly unit tested.)
--
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
More information about the Python-list
mailing list