About 10,500,000 results
Open links in new tab
  1. What is Python's equivalent of && (logical-and) in an if-statement?

    Mar 21, 2010 · As you can see only one print statement is executed, so Python really didn't even look at the right operand. This is not the case for the binary operators. Those always evaluate …

  2. What is the python keyword "with" used for? - Stack Overflow

    From Python Docs: The with statement clarifies code that previously would use try...finally blocks to ensure that clean-up code is executed. The with statement is a control-flow structure whose …

  3. python - Use and meaning of "in" in an if statement? - Stack …

    So, in JS, 1 in d will be true for an object if it has a member or method named '1', but in Python, it's up to your class what it means—Python will call d.__contains__(1), then, if that fails, it tries …

  4. Using or in if statement (Python) - Stack Overflow

    The left part may be false, but right part is true (python has "truth-y" and "fals-y" values), so the check always succeeds. The way to write what you meant to would be. if weather == "Good!" …

  5. Is there a "not equal" operator in Python? - Stack Overflow

    Jun 16, 2012 · Python is dynamically, but strongly typed, and other statically typed languages would complain about comparing different types. There's also the else clause: # This will …

  6. python - Pythonic way to combine for-loop and if-statement

    @KirillTitov Yes python is a fundamentally non-functional language (this is a purely imperative coding - and I agree with this answer's author that it is the way python is set up to be written. …

  7. Using both OR, AND in an IF-statement - Python - Stack Overflow

    Jun 26, 2022 · The in statement is arguable but fine either way. However for didactical purposes I only wanted to focus on the immediate problem and solution without bringing in a full code …

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

    Feb 8, 2019 · It is possible in Python 3 since v3.1 and Python 2.7. The new with syntax supports multiple context managers: with A() as a, B() as b, C() as c: doSomething(a,b,c)

  9. What is the difference between an expression and a statement in …

    Jan 18, 2011 · @Adalcar btw, even 5 + 5 alone in Python is a type of statement, know as an "expression statement", but is is not useful outside of the REPL. You could look at a statement …

  10. python - How to exit an if clause - Stack Overflow

    python if statement satisfied, don't continue script. 0 (Python 3.2):Exit when an if statement doesn't ...

Refresh