Cover image by Romain Vignes on Unsplash.
It's fall, so it seems like the perfect time to write some posts about PSL. Nope, not Pumpkin Spice Lat...
For further actions, you may consider blocking this person and/or reporting abuse
I know dicts are ordered by default from 3.7 onwards (so you could just use
defaultdict
), but I needed to mix thedefaultdict
andOrderedDict
at one point. Introducing theDefaultOrderedDict
:one example of how it can be used:
it will basically
deepcopy()
the contents of the default value.Neat! My first thought was to wonder if it could be done with multiple inheritance between defaultdict and OrderedDict, but that seems like that could be a big nightmare, so your method is probably cleaner. :)
If you're covering collections, why not also give a quick mention to Counter?
You're right! I wanted to dedicate another article to Counter. There's too much goodness for just a quick blurb :)
(From the article:)
Nice one, that's what I get for skimming the article and rushing to reply.
Love this idea of uncovering gems in the standard library :-)
Maybe I'll do one as well :)
Something like pymotw3 but about a single feature, not an entire module
Yeah I’ve got a few favorites that I’ve got planned 😁 you should definitely do one!
I already have one or two in mind :D I'll write about them soon