From 3d02a88b148b398858aac29da92cf8ffa92ede49 Mon Sep 17 00:00:00 2001 From: Robyn Speer Date: Tue, 16 Apr 2019 11:33:22 -0400 Subject: [PATCH] Protect top_n from running on import --- scripts/top_n.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/top_n.py b/scripts/top_n.py index 7b3b3ce..0db0518 100644 --- a/scripts/top_n.py +++ b/scripts/top_n.py @@ -8,7 +8,7 @@ import wordfreq N = 1000 - -for lang in sorted(wordfreq.available_languages()): - for word in wordfreq.top_n_list(lang, 1000): - print('{}\t{}'.format(lang, word)) +if __name__ == '__main__': + for lang in sorted(wordfreq.available_languages()): + for word in wordfreq.top_n_list(lang, 1000): + print('{}\t{}'.format(lang, word))