Re:Type hints – a mediocre programmer's reaction (2015)
by thristian on Thursday March 17, 2016 @06:43PM
(#11308235)
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...
[ Parent
| on HN ]
Re:Type hints – a mediocre programmer's reaction (2015)
by justanotherbody on Thursday March 17, 2016 @08:07PM
(#11308747)
I'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...
Re:Type hints – a mediocre programmer's reaction (2015)
by aidenn0 on Friday March 18, 2016 @12:23AM
(#11309888)
You have a seekable filelike interface that is a superset of the base filelike interface.
Re:Type hints – a mediocre programmer's reaction (2015)
by Retra on Thursday March 17, 2016 @09:35PM
(#11309209)
>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.