Skip to content
Advertisement

Counting dictionary elements from Perl to Python

Looking for a best way to translate this piece of code from Perl to Python:

JavaScript

If I understand it correctly the cycle above iterates through each element in arr array and how many time host appear, how many bytes count are related to it and errors…

But I don’t quite get the meaning of default variable $_, have Python background, not Perl.

UPDATE: after some brainstorming, I’ve come complete understanding of these Perl code but still not sure how to do it in Python, especially this piece:

JavaScript

Advertisement

Answer

Not tested but should be something like this:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement