About 89,800 results
Open links in new tab
  1. Are nested try/except blocks in Python a good programming …

    2 If try-except-finally is nested inside a finally block, the result from "child" finally is preserved. I have not found an official explanation yet, but the following code snippet shows this behavior …

  2. append - Nesting 'WITH' statements in Python - Stack Overflow

    Based on the Python docs, the second with statement will not execute until the first one has already begun. The compound with statement is semantically equivalent to nested with …

  3. Is there a better way to write nested if statements in python?

    Nov 19, 2019 · Without using another data structure, you could move the nested if-else statements into and conditions for the top level if-else statements. It would at least be more …

  4. python - Multiple variables in a 'with' statement? - Stack Overflow

    Feb 8, 2019 · 3 In Python 3.1+ you can specify multiple context expressions, and they will be processed as if multiple with statements were nested:

  5. python - nested "and/or" if statements - Stack Overflow

    Jul 28, 2017 · python list boolean-logic nested-if edited Jul 28, 2017 at 0:09 SeeDerekEngineer 780 2 7 23

  6. python - How to put nested if conditions in single line - Stack …

    May 11, 2020 · How to put nested if conditions in single line Asked 5 years, 7 months ago Modified 5 years, 7 months ago Viewed 1k times

  7. How to continue in nested loops in Python - Stack Overflow

    Feb 12, 2013 · How can you continue the parent loop of say two nested loops in Python? for a in b: for c in d: for e in f: if somecondition: <continue the for a in b lo...

  8. python - Nested if statements or And - Stack Overflow

    Jun 18, 2020 · Is a nested statement or the use of and in an if statement would be more efficient? Basically is: if condition1: if condition2: #do stuff or if condition1 and condition2: #do st...

  9. Are multiple `with` statements on one line equivalent to nested …

    Mar 31, 2017 · Yes, listing multiple with statements on one line is exactly the same as nesting them, according to the Python 2.7 language reference: With more than one item, the context …

  10. Nesting if statements in python - Stack Overflow

    Jan 27, 2016 · Indentation in python works almost like how curly braces in most other languages work. 4 spaces signals to the compiler that the block is indented, and so your code is actually …