'isa' keyword

  • Thread starter talin at acm dot org
  • Start date
T

Terry Hancock

Could you elaborate on that please?

It would indeed be better to have a keyword for querying whether
a class or object *implements* a given *interface*. Which is essentially
what "duck typing" does, albeit somewhat haphazardly. The formal
alternative, of using interfaces is provided by external packages
such as Zope and PyProtocols, but has never been standardized and
adopted into the standard library. Perhaps it should be.

Certainly as long as there is more than one implementation of
interfaces, support for testing them cannot be at the keyword
level and remains through functions and methods. This is actually
pretty easy to use, though.

Giving isinstance() a keyword status as "isa" would encourage
bad style, though, as it would attract beginners away from much
better styles such as component/interface design.

While that wouldn't necessarily be sufficient reason to *remove*
an "isa" keyword if one existed, it certainly detracts from the
desire to add one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,839
Latest member
MartinaBur

Latest Threads

Top