Remix.run Logo
motorest 21 hours ago

I'm definitely missing some key insight because after reading the article I felt it was a strawman argument.

Python already has conditional expressions, which already allow 'x if (predicate) else y'. Therefore in Python if is already equivalent to a function, and is composable.

Once you realize this, and also understand that Python has logical operators that can short-circuit, all Python examples feel convoluted and required the blogger to go way out of it's way to write nonidiomatic Python. If the goal was to make a point with Python, why not write Python?

middayc 21 hours ago | parent [-]

Python was used as an example because people know Python and reader can compare it to something known.

I wasn't trying to make Python look awkward. I was trying to write equivalent Python, you are very much welcome to suggest improvements to my Python examples.

Other languages could be used instead of Python, for example Javascript. But I feel Python is more contained language, with clear ways to do thing (I guess I don't know them that well :) )

motorest 16 hours ago | parent [-]

> Python was used as an example because people know Python and reader can compare it to something known.

I don't think you understood the point I made.

My point is that Python supports conditional expressions for years.

Support for conditional expressions already means that in Python indeed "if is just a function".

Therefore, the whole premise of the article is null and void, and the article is thus pointless.

This is evident to anyone who is familiar with Python. If you have any experience with Python and you are familiar with idiomatic Python and basic features such as list comprehension, you are already widely aware how "if is just a function".

> I wasn't trying to make Python look awkward. I was trying to write equivalent Python (...)

Except you didn't. You failed to even acknowledge that Python already supports "if is just a function" with basic aspects such as list comprehension.

This basic aspect of Python is covered quite prominently in intros to Python, but somehow you failed to even acknowledge it exists, and proceeded to base your argument on a patently false claim.

middayc 16 hours ago | parent [-]

If Python has special syntax for `if` and so makes if an expression, it doesn't mean that `if` is a function.

If `if` is a function why don't you call it like other functions in Python?

    if( .... )
Functions are first class in Python now AFAIK. Can you assign `if` to a variable?

Also, blog-posts is not just about `if`, is `for` a function in Python, `def`, `return`, `class`?