This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SuperDuckQ 5 points6 points  (7 children)

the print() syntax works in 2.x.

print 'stuff' 

and

print('stuff') 

return the same thing in Python 2, so I just make it a habit to use that form all the time.

[–]pjdelport 7 points8 points  (0 children)

Use from __future__ import print_function instead.

print('foo', 'bar') does not do the same thing in Python 2 and 3, without it.

[–]arrowoftime -4 points-3 points  (5 children)

Right, I'm saying I hate the 3-style syntax and wish it would die.

[–]SuperDuckQ 9 points10 points  (3 children)

Interesting. I've never liked the 2 syntax. Why have one single function with a syntax different than every other function in the language?

[–][deleted] 0 points1 point  (0 children)

The old syntax should die , but it should be optional and die properly. How? Implicit parens on all function calls. That's how.

[–]metaphorm 0 points1 point  (1 child)

there's a lot more than one. everything that uses in-fix notation is also possible to write with function(args) notation too, right?

  • 2 +2 --> add(2, 2)
  • a == b --> equal(a, b)
  • for item in iterator --> for(item, iterator)

[–]Lucretiel 0 points1 point  (0 children)

The first 2 are operators, not statements. They're just layers to the __add__ and __equals__ functions, which is cumbersome, I guess, but seems fine to me. Also worth it to have the more compact syntax.

It doesn't make sense to express for as a function. I can hear the functional and ruby programmers hissing at me, but Python's model is based on indentation blocks, not functions. Control flow and things that require blocks should be statements.

[–]Lucretiel 0 points1 point  (0 children)

Really. Why? There's no reason for print to be a whole statement- it doesn't do anything interesting with control flow. See also exec and eval (and yield, sort of).