Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from MarkNenadov/master

Port to Python 3.x (Without breaking Python 2.x suport)
  • Loading branch information...
commit c78feeadf6d622c974df7168a6badeac8aa8cd7b 2 parents d0b84e7 + 25226d0
@jdf authored
Showing with 8 additions and 8 deletions.
  1. +4 −4 haikufinder/__init__.py
  2. +4 −4 scripts/findhaikus
View
8 haikufinder/__init__.py
@@ -38,7 +38,7 @@
from __future__ import with_statement
import nltk
import re
-import cPickle as pickle
+import pickle
import gzip
import os.path
import sys
@@ -70,7 +70,7 @@ def read_alternates(which):
with open(file('cmudict/cmudict.pickle'), 'rb') as p:
syllables = pickle.load(p)
with open(file('cmudict/custom.dict'), 'r') as p:
- for line in p.xreadlines():
+ for line in p.readlines():
(word, count) = line.split()
syllables[word] = int(count)
@@ -190,10 +190,10 @@ def count_syllables(self):
for word in self.words:
syllable_count += self._count_syllables(self.clean(word))
except KeyError:
- print "I don't know '%s'"%word
+ print("I don't know '%s'"%word)
return -1
except Nope:
- print "I can't do '%s'"%word
+ print("I can't do '%s'"%word)
return -1
return syllable_count
View
8 scripts/findhaikus
@@ -35,7 +35,7 @@ try:
except:
text = sys.stdin.read()
for haiku in HaikuFinder(text).find_haikus():
- print haiku[0]
- print " %s" % haiku[1]
- print haiku[2]
- print
+ print(haiku[0])
+ print(" %s" % haiku[1])
+ print(haiku[2])
+ print()
Please sign in to comment.
Something went wrong with that request. Please try again.