4 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for vegaseat

With the advent of Python33 the module time has received a high resolution timer/counter. Here we use time.perf_counter() in a decorator to conveniently time two test functions.

3
2K
Member Avatar for vegaseat

A simple way to find duplicate words in a text. In this case the text is preprocessed to eliminate punctuation marks and set all words to lower case.

Member Avatar for paddy3118
2
4K
Member Avatar for vegaseat

This short snippet shows you how to preprocess a text to remove punctuation marks, then do a word frequency count using Counter() from the Python module collections. Finally, two sorts are applied to display words with matching frequency in alphabetical order.

2
655
Member Avatar for chriswelborn

I started using Python a few weeks ago, something finally clicked and I started writing tools for my personal use. I started writing something with a GUI using GTK and the code lines started multiplying rapidly, so I thought to myself "Am I commenting my source to death? How many …

Member Avatar for chriswelborn
2
357

The End.