Skip to content

Commit fd34eab

Browse files
committed
Merge pull request #3821 from hayd/FIX_some_prints
FIX py3ing some print statements
2 parents 36c1263 + 7e53089 commit fd34eab

File tree

21 files changed

+61
-50
lines changed

21 files changed

+61
-50
lines changed

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: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
__docformat__ = 'restructuredtext'
44

55
try:
6-
from pandas import hashtable, tslib, lib
7-
except ImportError as e: # pragma: no cover
8-
module = str(e).lstrip('cannot import name ') # hack but overkill to use re
9-
raise ImportError("C extensions: {0} not built".format(module))
6+
from . import hashtable, tslib, lib
7+
except Exception: # pragma: no cover
8+
import sys
9+
e = sys.exc_info()[1] # Py25 and Py3 current exception syntax conflict
10+
print (e)
11+
if 'No module named lib' in str(e):
12+
raise ImportError('C extensions not built: if you installed already '
13+
'verify that you are not importing from the source '
14+
'directory')
15+
else:
16+
raise
1017

1118
from datetime import datetime
1219
import numpy as np

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/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1899,4 +1899,4 @@ def _binify(cols, line_width):
18991899
1134250., 1219550., 855736.85, 1042615.4286,
19001900
722621.3043, 698167.1818, 803750.])
19011901
fmt = FloatArrayFormatter(arr, digits=7)
1902-
print fmt.get_result()
1902+
print (fmt.get_result())

pandas/core/groupby.py

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

14221422
if not self.as_index: # pragma: no cover
1423-
print 'Warning, ignoring as_index=True'
1423+
print ('Warning, ignoring as_index=True')
14241424

14251425
return ret
14261426

pandas/io/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def process_flags(flags=[]):
5555
try:
5656
FLAGS(flags)
5757
except gflags.FlagsError, e:
58-
print '%s\nUsage: %s ARGS\n%s' % (e, str(flags), FLAGS)
58+
print ('%s\nUsage: %s ARGS\n%s' % (e, str(flags), FLAGS))
5959
sys.exit(1)
6060

6161
# Set the logging according to the command-line flag.

pandas/io/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_quote_yahoo(symbols):
115115
lines = urllib2.urlopen(urlStr).readlines()
116116
except Exception, e:
117117
s = "Failed to download:\n{0}".format(e)
118-
print s
118+
print (s)
119119
return None
120120

121121
for line in lines:
@@ -467,7 +467,7 @@ def get_data_fred(name=None, start=dt.datetime(2010, 1, 1),
467467
start, end = _sanitize_dates(start, end)
468468

469469
if(name is None):
470-
print "Need to provide a name"
470+
print ("Need to provide a name")
471471
return None
472472

473473
fred_URL = "http://research.stlouisfed.org/fred2/series/"

pandas/io/parsers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def _clean_options(self, options, engine):
508508
sep = options['delimiter']
509509
if (sep is None and not options['delim_whitespace']):
510510
if engine == 'c':
511-
print 'Using Python parser to sniff delimiter'
511+
print ('Using Python parser to sniff delimiter')
512512
engine = 'python'
513513
elif sep is not None and len(sep) > 1:
514514
# wait until regex engine integrated
@@ -870,7 +870,7 @@ def _convert_to_ndarrays(self, dct, na_values, na_fvalues, verbose=False,
870870
coerce_type)
871871
result[c] = cvals
872872
if verbose and na_count:
873-
print 'Filled %d NA values in column %s' % (na_count, str(c))
873+
print ('Filled %d NA values in column %s' % (na_count, str(c)))
874874
return result
875875

876876
def _convert_types(self, values, na_values, try_num_bool=True):

pandas/io/pytables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def open(self, mode='a', warn=True):
386386
self._handle = h5_open(self._path, self._mode)
387387
except IOError, e: # pragma: no cover
388388
if 'can not be written' in str(e):
389-
print 'Opening %s in read-only mode' % self._path
389+
print ('Opening %s in read-only mode' % self._path)
390390
self._handle = h5_open(self._path, 'r')
391391
else:
392392
raise

pandas/io/sql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def execute(sql, con, retry=True, cur=None, params=None):
5151
except Exception: # pragma: no cover
5252
pass
5353

54-
print 'Error on sql %s' % sql
54+
print ('Error on sql %s' % sql)
5555
raise
5656

5757

@@ -94,7 +94,7 @@ def tquery(sql, con=None, cur=None, retry=True):
9494
except Exception, e:
9595
excName = e.__class__.__name__
9696
if excName == 'OperationalError': # pragma: no cover
97-
print 'Failed to commit, may need to restart interpreter'
97+
print ('Failed to commit, may need to restart interpreter')
9898
else:
9999
raise
100100

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

129129
traceback.print_exc()
130130
if retry:
131-
print 'Looks like your connection failed, reconnecting...'
131+
print ('Looks like your connection failed, reconnecting...')
132132
return uquery(sql, con, retry=False)
133133
return result
134134

0 commit comments

Comments
 (0)