3 ms·
I've had similarly weird errors in python, but given the same situations its ever occurred to me in ruby. Maybe its just the way the grammar is defined, for exa
by ben-schaaf 9y ago
I've had similarly weird errors in python, but given the same situations its ever occurred to me in ruby. Maybe its just the way the grammar is defined, for example stuff like the following works perfectly fine in ruby while python just says "Invalid Syntax":
foo = 1 +
2
- optimuspaul 9y agoyeah, ruby allows some odd stuff for sure.
- opportune 9y agoYou just need to add an escape character, "\". This is python 101 This is properly interpreted: foo = 1 + \ 2
- Too 9y agoPython will automatically escape newlines in some contexts. Another way to accomplish the above is to wrap the expression in parenthesis. foo = (1 + 2)
- ben-schaaf 9y agoOf course, the point I was making is that it's perfectly possible to write a parser that understands newline as a terminator without sacrificing these idiosyncrasies.