About 165,000 results
Open links in new tab
  1. How do I use a Boolean in Python? - Stack Overflow

    Does Python actually contain a Boolean value? I know that you can do: checker = 1 if checker: #dostuff But I'm quite pedantic and enjoy seeing booleans in Java. For instance: Boolean checker;...

  2. Evaluate boolean environment variable in Python - Stack Overflow

    Jul 27, 2020 · This will return True for any value of MY_ENV_VAR because the boolean value of any string is True in Python. Hence, also values like False, false, 0, etc. will end up as True.

  3. Converting "true" (JSON) to Python equivalent "True"

    Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'false' is not defined If I am not mistaken, I think this is because the boolean value in the JSON response is false / …

  4. Syntax for an If statement using a boolean - Stack Overflow

    I just recently joined the python3 HypeTrain. However I just wondered how you can use an if statement onto a boolean. Example: RandomBool = True # and now how can I check this in an if statement? L...

  5. python - How do I create a numpy array of all True or all False ...

    Jan 16, 2014 · Explanation: numpy creates arrays of all ones or all zeros very easily: e.g. numpy.ones((2, 2)) or numpy.zeros((2, 2)) Since True and False are represented in Python as 1 and …

  6. How can I map True/False to 1/0 in a Pandas DataFrame?

    I have a column in python pandas DataFrame that has boolean True/False values, but for further calculations I need 1/0 representation. Is there a quick pandas/numpy way to do that?

  7. python - Parsing boolean values with argparse - Stack Overflow

    I would like to use argparse to parse boolean command-line arguments written as "--foo True" or "--foo False". For example: my_program --my_boolean_flag False However, the following test code does...

  8. python - Is it safe to replace '==' with 'is' to compare Boolean-values ...

    There are cases where you need to compare booleans, for example when the boolean values are unknown at the compare-time. This need can easily emerge when you interpret the booleans more …

  9. python - How do "and" and "or" act with non-boolean values? - Stack ...

    Oct 30, 2017 · r1 = exp1 if exp1 else exp2 Where exp1 and exp2 are arbitrary python objects, or expressions that return some object. The key to understanding the uses of the logical and and or …

  10. python - How to toggle a value? - Stack Overflow

    345 Solution using NOT If the values are boolean, the fastest approach is to use the not operator: