From 60d3dd7604c49909588042c373277a4ce91cd07d Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 16 Nov 2017 21:47:25 +0100 Subject: python 3 conversion --- namegen.py | 12 ++++++------ 1 file 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() -- cgit v1.2.3