What for -- for? (was A bug?)
Zachary Ware
zachary.ware+pylist at gmail.com
Wed Oct 29 00:16:32 EDT 2014
On Tue, Oct 28, 2014 at 10:22 PM, Rustom Mody <rustompmody at gmail.com> wrote:
> How to see that list and range are both sequences?
> Or more generally how to to introspectively discover (ie not by reading docs!!)
> the abstract base classes -- eg sequence, iterable etc -- for an arbitrary
> object?
# Python 2/3 compatible. Combine with pprint for nice interactive output
try:
from collections import abc
except ImportError:
import collections as abc
def get_abc_map(cls):
return {n: issubclass(cls, getattr(abc, n)) for n in dir(abc) if
n[0].isupper()}
--
Zach
More information about the Python-list
mailing list