Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


You just need to add an escape character, "\". This is python 101

This is properly interpreted:

    foo = 1 + \
        2


Python will automatically escape newlines in some contexts. Another way to accomplish the above is to wrap the expression in parenthesis.

    foo = (1 +
           2)


Of 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.


yeah, ruby allows some odd stuff for sure.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: