4 ms·
Yeah, I immediately thought of Rust traits, which I hear are very like typeclasses. Python already has something like these, in the form of Abstract Base Classe
by thristian 11y ago
Yeah, I immediately thought of Rust traits, which I hear are very like typeclasses. Python already has something like these, in the form of Abstract Base Classes: collections.Callable for function-like things, collections.Iterable for things that conform to the iterator protocol... But if gradual typing is to be useful, it really needs ABCs for all the common ducks that Python code uses: file-like objects, things that dict() can convert into a dictionary, things that can be converted into strings...
- justanotherbody 11y agoI'm not sure any committee could agree as to what defines a filelike object (does it implement seek?) In addition you'd need an IRO (interface resolution order) if you truly intended to prove everything would work To say nothing of accidentally implementing an interface and getting an error because if it Doesn't sound like my kind of python...
- Retra 11y ago>I'm not sure any committee could agree as to what defines a filelike object (does it implement seek?) You step back a layer of abstraction. Maybe it implements seek, maybe it doesn't. Either way it implements has_seek.
- aidenn0 11y agoYou have a seekable filelike interface that is a superset of the base filelike interface.