Yes, Python 3's stricter model is less error prone (vs python 2 u').
the more annoying thing for me personally is the "print" function rather than previous "print" statement... Bugs the hell out of me.
Yes, Python 3's stricter model is less error prone (vs python 2 u').
the more annoying thing for me personally is the "print" function rather than previous "print" statement... Bugs the hell out of me.
The longer I do this, the more I see non-permissiveness in data validation as a feature and am actively happy to upgrade to get it. Ruby fixed their strings in 1.9 and it was one of the main reasons I was excited to upgrade our codebase to it. It was a pain to upgrade, but we found some real bugs, and were very happy with it after the fact. That the Python community has not embraced this yet completely mystifies me.
Maybe you're right about permissiveness if you're talking about syntax, but even then, I hate permissive syntax that increases ambiguity.
I realize this could also be done with the statement version of print, just by wrapping it in a function, using args, *kwargs, but it seems like the function version would be easier to use for this.
Of course, you would have to take care that all the functions you plan to pass to it, such as print and others, can do whatever is wanted to be done with it in the called code.
parent answered the question:
> Taking away permissiveness from a programming language just leads to developers not upgrade. No surprises there.
Some people used the print statement because at a time this was the recommended approach. In fact the 2.7 tutorial uses the statement: https://docs.python.org/2.7/tutorial/interpreter.html#intera... print behavior was changed, and combined with the other changes and incompatible modules a lot of people decided not to jump to 3.0.
Since languages like C never had a print statement to begin with -- printf was always a function call -- this issue would never have appeared in the first place.
IIRC ipython has a feature where you can prepend slash to any function (at the beginning of a line) to have parens inserted automatically, ie.
In [0]: /print "foo"
is executed as print("foo"). There - problem solved, and for all functions, not just one special case.Honestly, the crazy `print >>fileobject, "foo"` syntax is enough of a reason for removing it (print statement) from the language. It was unpythonic and I'm surprised it lasted this long in the language.
print (and I'd argue raise) aren't special enough to be statements, to have special syntactical rules, to be so special cause that works different.
Print statements are horrific though, totally agreed. It's just normal IO with a common default, but making it as a statement causes problems, e.g. `lambda: print 'yay'` isn't allowed.