top | item 45627506

(no title)

middayc | 4 months ago

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`?

discuss

order

motorest|4 months ago

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

The whole point is that yes, you can call it like a function, because Python supports it as an expression.

I seriously recommend you take the time to go through a Python tutoria.

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

Python supports list comprehension, so yes it is also about `for`.

Once you discover that Python supports conditional expressions and list comprehension, do you honestly believe the blog post has any merit? The blog post even shows a failure to do basic homework to verify what Python actually supports and not supports.