From 45d105e2fc79829324eef11de7c36e07f2d2f56e Mon Sep 17 00:00:00 2001 From: Prashant Patel Date: Fri, 16 Mar 2018 17:10:36 +0530 Subject: [PATCH 1/2] Added zen.txt file for chapter 3 --- 03-dict-set/index0.py | 2 +- 03-dict-set/index_default.py | 2 +- 03-dict-set/zen.txt | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 03-dict-set/zen.txt diff --git a/03-dict-set/index0.py b/03-dict-set/index0.py index e1fa28f..d591e7c 100644 --- a/03-dict-set/index0.py +++ b/03-dict-set/index0.py @@ -11,7 +11,7 @@ WORD_RE = re.compile('\w+') index = {} -with open(sys.argv[1], encoding='utf-8') as fp: +with open('zen.txt', encoding='utf-8') as fp: for line_no, line in enumerate(fp, 1): for match in WORD_RE.finditer(line): word = match.group() diff --git a/03-dict-set/index_default.py b/03-dict-set/index_default.py index 521b2d5..680680b 100644 --- a/03-dict-set/index_default.py +++ b/03-dict-set/index_default.py @@ -12,7 +12,7 @@ WORD_RE = re.compile('\w+') index = collections.defaultdict(list) # <1> -with open(sys.argv[1], encoding='utf-8') as fp: +with open('zen.txt', encoding='utf-8') as fp: for line_no, line in enumerate(fp, 1): for match in WORD_RE.finditer(line): word = match.group() diff --git a/03-dict-set/zen.txt b/03-dict-set/zen.txt new file mode 100644 index 0000000..048a1a3 --- /dev/null +++ b/03-dict-set/zen.txt @@ -0,0 +1,21 @@ +The Zen of Python, by Tim Peters + +Beautiful is better than ugly. +Explicit is better than implicit. +Simple is better than complex. +Complex is better than complicated. +Flat is better than nested. +Sparse is better than dense. +Readability counts. +Special cases aren't special enough to break the rules. +Although practicality beats purity. +Errors should never pass silently. +Unless explicitly silenced. +In the face of ambiguity, refuse the temptation to guess. +There should be one-- and preferably only one --obvious way to do it. +Although that way may not be obvious at first unless you're Dutch. +Now is better than never. +Although never is often better than *right* now. +If the implementation is hard to explain, it's a bad idea. +If the implementation is easy to explain, it may be a good idea. +Namespaces are one honking great idea -- let's do more of those! \ No newline at end of file From eda52608b7f1e09e9307f58b2a5f45452bed7f96 Mon Sep 17 00:00:00 2001 From: Prashant Patel Date: Fri, 16 Mar 2018 20:36:01 +0530 Subject: [PATCH 2/2] Updated file name --- 03-dict-set/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/03-dict-set/index.py b/03-dict-set/index.py index 3eac1fb..760dba1 100644 --- a/03-dict-set/index.py +++ b/03-dict-set/index.py @@ -11,7 +11,7 @@ WORD_RE = re.compile('\w+') index = {} -with open(sys.argv[1], encoding='utf-8') as fp: +with open('zen.txt', encoding='utf-8') as fp: for line_no, line in enumerate(fp, 1): for match in WORD_RE.finditer(line): word = match.group()