["python"]
Can we have assignment in a condition?

Is it possible to have assignment in a condition? For ex. if (a=some_func()): # Use a
Why not try it out? >>> def some_func(): ... return 2 ... >>> if (a = some_func()): File "<stdin>", line 1 if (a = some_func()): ^ SyntaxError: invalid syntax So, no. Update: This is possible (with different syntax) in Python 3.8 if a := some_func():