We can implement abstract interfaces (sequence, mapping, number) in Python with the appropriate __special__ methods, but i don't see an easy way to test if something supports one of these abstract interfaces in Python. At the moment, to see if something is a sequence i believe i have to say something like try: x[0] except: # not a sequence else: # okay, it's a sequence or if hasattr(x, '__getitem__') or type(x) in [type(()), type([])]: ... Is there, or should there be, a better way to do this? -- ?!ng
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4