Skip to content

Commit

Permalink
Use print() function in both Python 2 and Python 3 (apache#3440)
Browse files Browse the repository at this point in the history
Discovered via: __flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics__

Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3.
  • Loading branch information
cclauss authored and tqchen committed Jun 27, 2019
1 parent 5abbeb7 commit a074daf
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions nnvm/amalgamation/amalgamation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import print_function
import sys
import os.path, re, StringIO

Expand Down Expand Up @@ -69,21 +70,21 @@ def expand(x, pending):
return

if x in pending:
#print 'loop found: %s in ' % x, pending
#print('loop found: %s in ' % x, pending)
return

print >>out, "//===== EXPANDING: %s =====\n" %x
print("//===== EXPANDING: %s =====\n" % x, file=out)
for line in open(x):
if line.find('#include') < 0:
out.write(line)
continue
if line.strip().find('#include') > 0:
print line
print(line)
continue
m = re1.search(line)
if not m: m = re2.search(line)
if not m:
print line + ' not found'
print(line + ' not found')
continue
h = m.groups()[0].strip('./')
source = find_source(h, x)
Expand All @@ -94,7 +95,7 @@ def expand(x, pending):
'nnpack' not in h): sysheaders.append(h)
else:
expand(source, pending + [x])
print >>out, "//===== EXPANDED: %s =====\n" %x
print("//===== EXPANDED: %s =====\n" % x, file=out)
history.add(x)


Expand All @@ -105,12 +106,12 @@ def expand(x, pending):


for k in sorted(sysheaders):
print >>f, "#include <%s>" % k
print("#include <%s>" % k, file=f)

print >>f, ''
print >>f, out.getvalue()
print('', file=f)
print(out.getvalue(), file=f)

for x in sources:
if x not in history and not x.endswith('.o'):
print 'Not processed:', x
print('Not processed:', x)

0 comments on commit a074daf

Please sign in to comment.