diff options
author | Steven Myint <git@stevenmyint.com> | 2013-10-04 08:14:19 -0700 |
---|---|---|
committer | Steven Myint <git@stevenmyint.com> | 2013-10-04 08:14:19 -0700 |
commit | 1cb3226c9d2e57b8ec280433c2ad7c990d63bae0 (patch) | |
tree | 87a6f6019ac0d9ee81b3db2b93ac704be458a75c /examples/chess2.py | |
parent | dd0479cb32e55e882a8d1391af2d5b37f25e2db7 (diff) | |
download | pexpect-1cb3226c9d2e57b8ec280433c2ad7c990d63bae0.tar.gz |
Modernize
Diffstat (limited to 'examples/chess2.py')
-rwxr-xr-x | examples/chess2.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/chess2.py b/examples/chess2.py index 7fe959a..ae5fcea 100755 --- a/examples/chess2.py +++ b/examples/chess2.py @@ -22,6 +22,10 @@ PEXPECT LICENSE ''' +from __future__ import print_function + +from __future__ import absolute_import + import pexpect import string import ANSI @@ -49,8 +53,8 @@ class Chess: while self.term.cur_r != r or self.term.cur_c != c: try: k = self.child.read(1, 10) - except Exception, e: - print 'EXCEPTION, (r,c):(%d,%d)\n' %(self.term.cur_r, self.term.cur_c) + except Exception as e: + print('EXCEPTION, (r,c):(%d,%d)\n' %(self.term.cur_r, self.term.cur_c)) sys.stdout.flush() self.term.process (k) fout.write ('(r,c):(%d,%d)\n' %(self.term.cur_r, self.term.cur_c)) @@ -61,7 +65,7 @@ class Chess: if self.term.cur_r == r and self.term.cur_c == c: fout.close() return 1 - print 'DIDNT EVEN HIT.' + print('DIDNT EVEN HIT.') fout.close() return 1 @@ -106,7 +110,7 @@ class Chess: return cm def switch (self): - print 'switching' + print('switching') self.child.sendline ('switch') def set_depth (self, depth): @@ -118,13 +122,13 @@ class Chess: self.child.sendline ('quit') def LOG (s): - print s + print(s) sys.stdout.flush () fout = open ('moves.log', 'a') fout.write (s + '\n') fout.close() -print 'Starting...' +print('Starting...') black = Chess() white = Chess() |