Skip to content

Bug on line 63 (or). #3

@cjwelborn

Description

@cjwelborn

This line doesn't do what you think it does. It is parsed like this:

if ('test' == 'nada') or 'nothing':
    print('ok')
else:
    print('nope')

Which will always execute, because even though 'test' != 'nada', 'nothing' is truthy because of bool(non-empty-str). It's the same as if False or True:.

The better way would be:

if 'test' in ('nada', 'nothing'):
    print('ok')

I rewrote this for Python 3, using a dict-style instead of if-else, and reformatted the output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions