#29 assert is a keyword, not a function

open
nobody
None
5
2005-07-29
2005-07-29
No

It would be nice if pychecker could warn when assert
is called with a tuple, ie. looking like a function call.

assert(exp,"message")

assert is particularly dangerous when used like this.
print will do something, assert will do nothing, ever.

Warning on other statements could still be good though.

Discussion

  • Neal Norwitz
    Neal Norwitz
    2005-08-31

    Logged In: YES
    user_id=33168

    This should be implemented currently. Do you have an
    example where it doesn't work?

    *** Here's the code:

    neal@janus pychecker $ cat tt.py

    def f(exp):
    assert(exp,"message")
    print 'hi there'

    *** And the results:

    neal@janus pychecker $ ./pychecker/checker.py tt.py
    Processing tt...

    Warnings...

    tt.py:3: Using a conditional statement with a constant value
    ((exp, message))