Re: [Python-ideas] collections.Counter should implement fromkeys

[Michael Selik]
Because, as in my original example code; the values could be zero or they could be more, I just want to make sure the keys are in the counter when I iterate. I'm not having any trouble finding a work around. I'm having trouble understanding why I need to find a work around when Counter already inherits from dict, dict.fromkeys is perfectly well defined, and there's not really any other *obvious* best way to initialize the value for a set of keys. Counter(dict.fromkeys(keys, value)) works just fine, but it feels wrong. I'm using the copy-constructor because I know Counter is a subclass of dict. I'm using fromkeys because I know how that class method works. So why does the subclass lack functionality that the superclass has? Because programmers wouldn't be able to wrap their heads around it? I don't buy it. This feels like nanny-design trumping SOLID design <https://en.wikipedia.org/wiki/SOLID>.
participants (1)
-
Abe Dillon