7 ms·
That reminds me of the very specific nag messages I get from Python 3 when I don't write parens around parameters for print... do what I want already.
by zorked 8y ago
That reminds me of the very specific nag messages I get from Python 3 when I don't write parens around parameters for print... do what I want already.
- robdachshund 8y agoIf print() is a function why should you be able to call it like that? Python 3 was just fixing that inconsistency. Functions have their arguments inside of parentheses. Should we be able to call "requests.post url, data"? It sounds like you are upset with the language for resolving something that never made sense to begin with.
- pseudalopex 8y agoWhat does someone want if they write "bar = print foo,"? Is it the same if "print" isn't the built-in function?
- shaki-dora 8y agoOperator precedence isn't really a new concept, and Python relies on it in plenty other situations: bar = 1 + 1 I do believe Python made the right call, actually: print needed to be unified with functions, and dropping the requirement for parenthesis for function calls would have introduced so much incompatibility as to make the Python 2 -> 3 transition far more difficult. But ignoring the legacy issue, there is a better way to do function calls, and it is ruby.
- pseudalopex 8y agoWhat does operator precedence have to do with this? Ending a parameter list with a comma changes the output of the print keyword but not a function. Assignment statements can contain function calls but not the print keyword. C style function calls are common, explicit, and consistent. Python adds the best combination of positional, variadic, and named parameters of any language I know. ML style has less punctuation and simpler grouping rules. Ruby has the weaknesses of both.
- arbie 8y agoDidn't Ruby borrow it from Perl?
- epse 8y agoAnd lisp, just less parentheses
- shrimpx 8y agoHaskell/ml/caml do it better than Ruby. f 1 2 (f 1 2).thing Here the parentheses are nothing special, they just hint precedence. As opposed to f 1, 2 f(1, 2).thing Awkward special-case commas and parentheses.
- eequah9L 8y agoThat usage doesn't get the weirdly specific error message though. It's only the Python2-ish statement that gets one.
- pseudalopex 8y agoWhat does someone want "print foo" to do if "print" is a different function? What does someone want "print (1, 2)" to do if "print" is the built-in function? It prints a tuple in Python 2 and ints in Python 3.
- eequah9L 8y agoI get that. So the Python 3 interpreter has to assume that when I say "print (1, 2)", I actually mean, print these two individual arguments. If I say "print 'foo'" though, it recommends "print ('foo')", but doesn't go all the way to assume I actually meant that. There's a piece of code handling that special case that stops short of actually interpreting what I apparently mean. The frustration around that was the original point.
- nightfly 8y agoIn Python 3 there was an explicit decision not to support print as a statement, and rather as a function call.
- garmaine 8y agoYou missed the point... that decision should have been made.