Skip to content

Commit 3bed383

Browse files
committed
General print statement cleanup.
1 parent 230cbc4 commit 3bed383

30 files changed

+103
-103
lines changed

bench/io_roundtrip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def rountrip_archive(N, K=50, iterations=10):
6262
pickle_time = timeit(pickle_f, iterations) / iterations
6363
print('pandas (pickle) %7.4f seconds' % pickle_time)
6464

65-
# print 'Numpy (npz) %7.4f seconds' % numpy_time
66-
# print 'larry (HDF5) %7.4f seconds' % larry_time
65+
# print('Numpy (npz) %7.4f seconds' % numpy_time)
66+
# print('larry (HDF5) %7.4f seconds' % larry_time)
6767

6868
# Delete old files
6969
try:

doc/sphinxext/docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def __str__(self):
463463

464464
if self._role:
465465
if not roles.has_key(self._role):
466-
print "Warning: invalid role %s" % self._role
466+
print("Warning: invalid role %s" % self._role)
467467
out += '.. %s:: %s\n \n\n' % (roles.get(self._role, ''),
468468
func_name)
469469

doc/sphinxext/ipython_console_highlighting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class IPythonConsoleLexer(Lexer):
3939
In [2]: a
4040
Out[2]: 'foo'
4141
42-
In [3]: print a
42+
In [3]: print(a)
4343
foo
4444
4545
In [4]: 1 / 0

doc/sphinxext/ipython_directive.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ def block_parser(part, rgxin, rgxout, fmtin, fmtout):
158158

159159
nextline = lines[i]
160160
matchout = rgxout.match(nextline)
161-
# print "nextline=%s, continuation=%s, starts=%s"%(nextline,
162-
# continuation, nextline.startswith(continuation))
161+
# print("nextline=%s, continuation=%s, starts=%s"%(nextline,
162+
# continuation, nextline.startswith(continuation)))
163163
if matchout or nextline.startswith('#'):
164164
break
165165
elif nextline.startswith(continuation):
@@ -245,7 +245,7 @@ def clear_cout(self):
245245

246246
def process_input_line(self, line, store_history=True):
247247
"""process the input, capturing stdout"""
248-
# print "input='%s'"%self.input
248+
# print("input='%s'"%self.input)
249249
stdout = sys.stdout
250250
splitter = self.IP.input_splitter
251251
try:
@@ -293,7 +293,7 @@ def process_input(self, data, input_prompt, lineno):
293293
decorator, input, rest = data
294294
image_file = None
295295
image_directive = None
296-
# print 'INPUT:', data # dbg
296+
# print('INPUT:', data) # dbg
297297
is_verbatim = decorator == '@verbatim' or self.is_verbatim
298298
is_doctest = decorator == '@doctest' or self.is_doctest
299299
is_suppress = decorator == '@suppress' or self.is_suppress
@@ -361,7 +361,7 @@ def _remove_first_space_if_any(line):
361361
self.cout.truncate(0)
362362
return (ret, input_lines, output, is_doctest, image_file,
363363
image_directive)
364-
# print 'OUTPUT', output # dbg
364+
# print('OUTPUT', output) # dbg
365365

366366
def process_output(self, data, output_prompt,
367367
input_lines, output, is_doctest, image_file):
@@ -390,9 +390,9 @@ def process_output(self, data, output_prompt,
390390
'found_output="%s" and submitted output="%s"' %
391391
(input_lines, found, submitted))
392392
raise RuntimeError(e)
393-
# print 'doctest PASSED for input_lines="%s" with
394-
# found_output="%s" and submitted output="%s"'%(input_lines,
395-
# found, submitted)
393+
# print('''doctest PASSED for input_lines="%s" with
394+
# found_output="%s" and submitted output="%s"''' % (input_lines,
395+
# found, submitted))
396396

397397
def process_comment(self, data):
398398
"""Process data fPblock for COMMENT token."""
@@ -406,7 +406,7 @@ def save_image(self, image_file):
406406
self.ensure_pyplot()
407407
command = ('plt.gcf().savefig("%s", bbox_inches="tight", '
408408
'dpi=100)' % image_file)
409-
# print 'SAVEFIG', command # dbg
409+
# print('SAVEFIG', command) # dbg
410410
self.process_input_line('bookmark ipy_thisdir', store_history=False)
411411
self.process_input_line('cd -b ipy_savedir', store_history=False)
412412
self.process_input_line(command, store_history=False)
@@ -737,12 +737,12 @@ def run(self):
737737
lines.extend(figure.split('\n'))
738738
lines.append('')
739739

740-
# print lines
740+
# print(lines)
741741
if len(lines) > 2:
742742
if debug:
743-
print '\n'.join(lines)
743+
print('\n'.join(lines))
744744
else: # NOTE: this raises some errors, what's it for?
745-
# print 'INSERTING %d lines'%len(lines)
745+
# print('INSERTING %d lines' % len(lines))
746746
self.state_machine.insert_input(
747747
lines, self.state_machine.input_lines.source(0))
748748

@@ -813,7 +813,7 @@ def test():
813813
In [130]: url = 'http://ichart.finance.yahoo.com/table.csv?s=CROX\
814814
.....: &d=9&e=22&f=2009&g=d&a=1&br=8&c=2006&ignore=.csv'
815815
816-
In [131]: print url.split('&')
816+
In [131]: print(url.split('&'))
817817
['http://ichart.finance.yahoo.com/table.csv?s=CROX', 'd=9', 'e=22', 'f=2009', 'g=d', 'a=1', 'b=8', 'c=2006', 'ignore=.csv']
818818
819819
In [60]: import urllib
@@ -843,12 +843,12 @@ def test():
843843
""",
844844

845845
r"""
846-
In [106]: print x
846+
In [106]: print(x)
847847
jdh
848848
849849
In [109]: for i in range(10):
850850
n
851-
.....: print i
851+
.....: print(i)
852852
.....:
853853
.....:
854854
0
@@ -920,4 +920,4 @@ def test():
920920
if not os.path.isdir('_static'):
921921
os.mkdir('_static')
922922
test()
923-
print 'All OK? Check figures in _static/'
923+
print('All OK? Check figures in _static/')

doc/sphinxext/phantom_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def setup(app):
3131
def initialize(app):
3232
fn = app.config.phantom_import_file
3333
if (fn and os.path.isfile(fn)):
34-
print "[numpydoc] Phantom importing modules from", fn, "..."
34+
print("[numpydoc] Phantom importing modules from", fn, "...")
3535
import_phantom_module(fn)
3636

3737
#------------------------------------------------------------------------------

doc/sphinxext/tests/test_docscrape.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@
8585
>>> mean = (1,2)
8686
>>> cov = [[1,0],[1,0]]
8787
>>> x = multivariate_normal(mean,cov,(3,3))
88-
>>> print x.shape
88+
>>> print(x.shape)
8989
(3, 3, 2)
9090
9191
The following is probably true, given that 0.6 is roughly twice the
9292
standard deviation:
9393
94-
>>> print list( (x[0,0,:] - mean) < 0.6 )
94+
>>> print(list( (x[0,0,:] - mean) < 0.6 ))
9595
[True, True]
9696
9797
.. index:: random
@@ -153,7 +153,7 @@ def test_examples():
153153

154154
def test_index():
155155
assert_equal(doc['index']['default'], 'random')
156-
print doc['index']
156+
print(doc['index'])
157157
assert_equal(len(doc['index']), 2)
158158
assert_equal(len(doc['index']['refguide']), 2)
159159

@@ -247,13 +247,13 @@ def test_str():
247247
>>> mean = (1,2)
248248
>>> cov = [[1,0],[1,0]]
249249
>>> x = multivariate_normal(mean,cov,(3,3))
250-
>>> print x.shape
250+
>>> print(x.shape)
251251
(3, 3, 2)
252252
253253
The following is probably true, given that 0.6 is roughly twice the
254254
standard deviation:
255255
256-
>>> print list( (x[0,0,:] - mean) < 0.6 )
256+
>>> print(list( (x[0,0,:] - mean) < 0.6 ))
257257
[True, True]
258258
259259
.. index:: random
@@ -351,13 +351,13 @@ def test_sphinx_str():
351351
>>> mean = (1,2)
352352
>>> cov = [[1,0],[1,0]]
353353
>>> x = multivariate_normal(mean,cov,(3,3))
354-
>>> print x.shape
354+
>>> print(x.shape)
355355
(3, 3, 2)
356356
357357
The following is probably true, given that 0.6 is roughly twice the
358358
standard deviation:
359359
360-
>>> print list( (x[0,0,:] - mean) < 0.6 )
360+
>>> print(list( (x[0,0,:] - mean) < 0.6 ))
361361
[True, True]
362362
""")
363363

examples/regressions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def makeSeries():
3131

3232
model = ols(y=Y, x=X)
3333

34-
print (model)
34+
print(model)
3535

3636
#-------------------------------------------------------------------------------
3737
# Panel regression
@@ -48,4 +48,4 @@ def makeSeries():
4848

4949
model = ols(y=Y, x=data)
5050

51-
print (panelModel)
51+
print(panelModel)

pandas/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
except Exception: # pragma: no cover
88
import sys
99
e = sys.exc_info()[1] # Py25 and Py3 current exception syntax conflict
10-
print (e)
10+
print(e)
1111
if 'No module named lib' in str(e):
1212
raise ImportError('C extensions not built: if you installed already '
1313
'verify that you are not importing from the source '

pandas/core/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _describe_option(pat='', _print_desc=True):
154154
s += _build_option_description(k)
155155

156156
if _print_desc:
157-
print (s)
157+
print(s)
158158
else:
159159
return s
160160

@@ -631,7 +631,7 @@ def pp(name, ks):
631631
ls += pp(k, ks)
632632
s = '\n'.join(ls)
633633
if _print:
634-
print (s)
634+
print(s)
635635
else:
636636
return s
637637

pandas/core/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,9 @@ def iterrows(self):
724724
725725
>>> df = DataFrame([[1, 1.0]], columns=['x', 'y'])
726726
>>> row = next(df.iterrows())[1]
727-
>>> print row['x'].dtype
727+
>>> print(row['x'].dtype)
728728
float64
729-
>>> print df['x'].dtype
729+
>>> print(df['x'].dtype)
730730
int64
731731
732732
Returns

pandas/core/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ def aggregate(self, func_or_funcs, *args, **kwargs):
14321432
ret = Series(result, index=index)
14331433

14341434
if not self.as_index: # pragma: no cover
1435-
print ('Warning, ignoring as_index=True')
1435+
print('Warning, ignoring as_index=True')
14361436

14371437
return ret
14381438

pandas/io/parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def _clean_options(self, options, engine):
516516
sep = options['delimiter']
517517
if (sep is None and not options['delim_whitespace']):
518518
if engine == 'c':
519-
print ('Using Python parser to sniff delimiter')
519+
print('Using Python parser to sniff delimiter')
520520
engine = 'python'
521521
elif sep is not None and len(sep) > 1:
522522
# wait until regex engine integrated

pandas/io/pytables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def open(self, mode='a'):
503503
self._handle = h5_open(self._path, self._mode)
504504
except IOError as e: # pragma: no cover
505505
if 'can not be written' in str(e):
506-
print ('Opening %s in read-only mode' % self._path)
506+
print('Opening %s in read-only mode' % self._path)
507507
self._handle = h5_open(self._path, 'r')
508508
else:
509509
raise

pandas/io/sql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def tquery(sql, con=None, cur=None, retry=True):
9797
except Exception as e:
9898
excName = e.__class__.__name__
9999
if excName == 'OperationalError': # pragma: no cover
100-
print ('Failed to commit, may need to restart interpreter')
100+
print('Failed to commit, may need to restart interpreter')
101101
else:
102102
raise
103103

@@ -131,7 +131,7 @@ def uquery(sql, con=None, cur=None, retry=True, params=None):
131131

132132
traceback.print_exc()
133133
if retry:
134-
print ('Looks like your connection failed, reconnecting...')
134+
print('Looks like your connection failed, reconnecting...')
135135
return uquery(sql, con, retry=False)
136136
return result
137137

pandas/io/tests/test_pytables.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,15 +1328,15 @@ def test_big_table_frame(self):
13281328
recons = store.select('df')
13291329
assert isinstance(recons, DataFrame)
13301330

1331-
print ("\nbig_table frame [%s] -> %5.2f" % (rows, time.time() - x))
1331+
print("\nbig_table frame [%s] -> %5.2f" % (rows, time.time() - x))
13321332

13331333
def test_big_table2_frame(self):
13341334
# this is a really big table: 1m rows x 60 float columns, 20 string, 20 datetime
13351335
# columns
13361336
raise nose.SkipTest('no big table2 frame')
13371337

13381338
# create and write a big table
1339-
print ("\nbig_table2 start")
1339+
print("\nbig_table2 start")
13401340
import time
13411341
start_time = time.time()
13421342
df = DataFrame(np.random.randn(1000 * 1000, 60), index=range(int(
@@ -1346,8 +1346,8 @@ def test_big_table2_frame(self):
13461346
for x in range(20):
13471347
df['datetime%03d' % x] = datetime.datetime(2001, 1, 2, 0, 0)
13481348

1349-
print ("\nbig_table2 frame (creation of df) [rows->%s] -> %5.2f"
1350-
% (len(df.index), time.time() - start_time))
1349+
print("\nbig_table2 frame (creation of df) [rows->%s] -> %5.2f"
1350+
% (len(df.index), time.time() - start_time))
13511351

13521352
def f(chunksize):
13531353
with ensure_clean(self.path,mode='w') as store:
@@ -1357,15 +1357,15 @@ def f(chunksize):
13571357

13581358
for c in [10000, 50000, 250000]:
13591359
start_time = time.time()
1360-
print ("big_table2 frame [chunk->%s]" % c)
1360+
print("big_table2 frame [chunk->%s]" % c)
13611361
rows = f(c)
1362-
print ("big_table2 frame [rows->%s,chunk->%s] -> %5.2f"
1363-
% (rows, c, time.time() - start_time))
1362+
print("big_table2 frame [rows->%s,chunk->%s] -> %5.2f"
1363+
% (rows, c, time.time() - start_time))
13641364

13651365
def test_big_put_frame(self):
13661366
raise nose.SkipTest('no big put frame')
13671367

1368-
print ("\nbig_put start")
1368+
print("\nbig_put start")
13691369
import time
13701370
start_time = time.time()
13711371
df = DataFrame(np.random.randn(1000 * 1000, 60), index=range(int(
@@ -1375,17 +1375,17 @@ def test_big_put_frame(self):
13751375
for x in range(20):
13761376
df['datetime%03d' % x] = datetime.datetime(2001, 1, 2, 0, 0)
13771377

1378-
print ("\nbig_put frame (creation of df) [rows->%s] -> %5.2f"
1379-
% (len(df.index), time.time() - start_time))
1378+
print("\nbig_put frame (creation of df) [rows->%s] -> %5.2f"
1379+
% (len(df.index), time.time() - start_time))
13801380

13811381
with ensure_clean(self.path, mode='w') as store:
13821382
start_time = time.time()
13831383
store = HDFStore(self.path, mode='w')
13841384
store.put('df', df)
13851385

1386-
print (df.get_dtype_counts())
1387-
print ("big_put frame [shape->%s] -> %5.2f"
1388-
% (df.shape, time.time() - start_time))
1386+
print(df.get_dtype_counts())
1387+
print("big_put frame [shape->%s] -> %5.2f"
1388+
% (df.shape, time.time() - start_time))
13891389

13901390
def test_big_table_panel(self):
13911391
raise nose.SkipTest('no big table panel')
@@ -1410,7 +1410,7 @@ def test_big_table_panel(self):
14101410
recons = store.select('wp')
14111411
assert isinstance(recons, Panel)
14121412

1413-
print ("\nbig_table panel [%s] -> %5.2f" % (rows, time.time() - x))
1413+
print("\nbig_table panel [%s] -> %5.2f" % (rows, time.time() - x))
14141414

14151415
def test_append_diff_item_order(self):
14161416

pandas/io/wb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def download(country=['MX', 'CA', 'US'], indicator=['GDPPCKD', 'GDPPCKN'],
6868
# Warn
6969
if len(bad_indicators) > 0:
7070
print('Failed to obtain indicator(s): %s' % '; '.join(bad_indicators))
71-
print ('The data may still be available for download at http://data.worldbank.org')
71+
print('The data may still be available for download at http://data.worldbank.org')
7272
if len(bad_countries) > 0:
7373
print('Invalid ISO-2 codes: %s' % ' '.join(bad_countries))
7474
# Merge WDI series

pandas/stats/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def ols(**kwargs):
6464
6565
# Run rolling simple OLS with window of size 10.
6666
result = ols(y=y, x=x, window_type='rolling', window=10)
67-
print result.beta
67+
print(result.beta)
6868
6969
result = ols(y=y, x=x, nw_lags=1)
7070

0 commit comments

Comments
 (0)