[Python-ideas] Revisiting Immutable Mappings
Chris Barker - NOAA Federal
chris.barker at noaa.gov
Thu Oct 11 11:40:07 EDT 2018
> This violates the Liskov Substitution Principle.
If we REALLY had a time machine, then dict would subclass frozendict,
and we’d be all set.
But to what extent do we need to support ALL the ways to check for an
Personally, I think EAFTP is the most “Pythonic”, but if folks want to
check up front, then isn’t that what ABCs are for? In which case , we
already have Mapping and MutableMapping.
So if you have code that checks for Mapping when you need it mutable,
then that’s arguably a bug.
And if you code checks for dict directly, then it’s arguably unpythonic.
That being said, it probably is best not to break working code.
Would there be unpleasant consequences to making dict a subclass of FrozenDict ?
Or maybe come up with a new name: after all, lists and tuples are
independent, even though you *could* think of a tuple as a FrozenList
More information about the Python-ideas