summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-11-16 21:47:25 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-11-16 21:47:25 +0100
commit60d3dd7604c49909588042c373277a4ce91cd07d (patch)
tree81fc1b2ac3e1b38b6277fe5c1d0311b29531985b
parentf89d77607c5cde89756936a2f3415d39dff433cc (diff)
python 3 conversion
-rwxr-xr-xnamegen.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/namegen.py b/namegen.py
index 7eb2c86..7419331 100755
--- a/namegen.py
+++ b/namegen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
namegen.py
@@ -96,15 +96,15 @@ class Stats:
for name in fp.readlines():
name = name.decode('utf-8')
- for i in xrange(min(self.context,len(name))):
+ for i in range(min(self.context,len(name))):
self._increment_stats(name[0:i],name[i])
- for i in xrange(self.context,len(name)):
+ for i in range(self.context,len(name)):
self._increment_stats(name[i-self.context:i],name[i])
def load_stats(self,fp):
"""Load stats from json in a file-like object."""
self.stats = json.load(fp)
- self.context = max([len(k) for k in self.stats.keys()])
+ self.context = max([len(k) for k in list(self.stats.keys())])
def save_stats(self,fp):
"""Save stats in json to a file-like object."""
@@ -199,8 +199,8 @@ def main():
except (TypeError, ValueError):
n = 1
- for i in xrange(n):
- print mystats.generate_name(),
+ for i in range(n):
+ print(mystats.generate_name(), end=' ')
if __name__ == '__main__': main()