[Michael Selik] 

> You need an iterable of the keys you're interested in to pass to the 
> hypothetical ``fromkeys`` method. Why not iterate over that same iterable 
> paired with zeros instead of passing it into ``fromkeys``? 
>

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>.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to