[Python-ideas] collections.Counter should implement fromkeys

Abe Dillon abedillon at gmail.com
Fri Jun 29 20:55:44 EDT 2018


[Michael Selik] 

> You might be pursuing a local optimum of obviousness. If you step back 
> from the idea of "initialize the counts with all interesting keys" and 
> looping over them, you might find a better overall solution.
>

That's a distinct possibility, but this is far from the first time I've 
wanted for a better way to initialize a Counter. It's just a simple example 
for which there are many many alternative approaches.

If' you're interested, I have a more complete implementation of the game of 
life here <https://repl.it/@AbeDillon/Life>.

[Michael Selik] 

> That happens more frequently than my OOP professor seemed to think. I end 
> up with platypi (platypuses?) all too often.


Yes, I always try to caution my own students against strict adherence to 
any ideology, methodology, or cult.
"Always do this" and "Never do that" rules are useful crutches for novices 
trying to navigate the complex world of coding for the first time,
but pros are the ones who are experienced enough to know when it's OK to 
break the rules. When GoTo isn't harmful. When to break the rule of thirds 
<https://www.youtube.com/watch?v=hyGAgqfoUo8>.

Obviously, Python breaks SOLID principals successfully all over the place 
for pragmatic reasons.
I don't think this is one of those cases.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180629/672dee7f/attachment.html>


More information about the Python-ideas mailing list