print() with no newline

ElChino elchino at cnn.cn
Sun Dec 18 07:25:21 EST 2016


In this snippet:
  import sys
  PY3 = (sys.version_info[0] >= 3)

  def print_no_nl (s):
    if PY3:
      print (s, end="")
    else:
      print (s),

I'm getting a syntax error in Python2. Python3 is fine.
How can I make this Py2+3 compatible?



More information about the Python-list mailing list