Hacker News new | past | comments | ask | show | jobs | submit login

I don't understand, he seems to be dealing with that syntax like two lines later?

...

“But wait! Python has a ternary condi­tional expres­sion!” It doesn’t change the essen­tial point, but OK—you can indeed write this:

42 + (100 if 1 < 0 else 200)

But now suppose we want to use a condi­tional in place of the oper­ator, not the right-hand value. In a Lisp, because every­thing is an expres­sion—including the oper­ator itself—this is easy:

((if (< 1 0) + * ) 42 100)

But if you try the same thing in Python, it will raise a syntax error:

42 (+ if 1 < 0 else * ) 100

...




Hmm, my mistake I stopped reading after I saw he said something false. Guess I should read the whole thing instead of dismissing something after I see a false statement.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: