A
A
Alexey Poloz2017-06-07 00:28:26
Python
Alexey Poloz, 2017-06-07 00:28:26

Python What is the fundamental difference in writing a condition?

Is there a difference in the execution time of such structures?
And which construction is considered more readable?

if <громадное условие>:
   func(x,y,z)

And
func(x,y,z) if <громадное условие>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2017-06-07
@kosyachniy

The difference is that the second construct requires an else

A
Anatoly Scherbakov, 2017-06-07
@Altaisoft

Let me add to the words of other commentators: it is usually better not to make "enormous conditions", they are difficult to read. Almost always, you can somehow optimize and reduce it, for example, by decomposing it into separate variables, or making a list and setting any()/ on it all(), or taking it all into a separate function with a bunch of assert, instead of catching the condition AssertionError.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question