Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. >>> print "hello World"
  2. File "<stdin>", line 1
  3. print "hello World"
  4. ^
  5. SyntaxError: invalid syntax
  6.  
  7. print("Hello World")
  8.  
  9. print('Hello world!')
  10.  
  11. print("Hello world")
  12.  
  13. print("hello World")
  14.  
  15. print("Hello World")
  16.  
  17. from __future__ import print_function
  18.  
  19. Old: print "The answer is", 2*2
  20. New: print("The answer is", 2*2)
  21.  
  22. Old: print x, # Trailing comma suppresses newline
  23. New: print(x, end=" ") # Appends a space instead of a newline
  24.  
  25. Old: print # Prints a newline
  26. New: print() # You must call the function!
  27.  
  28. Old: print >>sys.stderr, "fatal error"
  29. New: print("fatal error", file=sys.stderr)
  30.  
  31. Old: print (x, y) # prints repr((x, y))
  32. New: print((x, y)) # Not the same as print(x, y)!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement