I want to call a method f()
, but accidentally I just say f
. Python3 mistakes this for a meaningless evaluation of a nonexisting variable, and therefore skips over my intended method call without any notice. Is there a way to override this default behavior and to get an error message? Either by forbidding dual use of an identifier as a method and as a variable, or by forbidding a meaningless statement consisting just of an identifier?
It's valid syntax, so Python won't complain. You may want to consider some other tools, like pylint. Pylint would've reported:
W: 4,0: Statement seems to have no effect
If you simply did:
f
instead of:
f()
The only catch is the pylint can complain an awful lot out of the box. Make sure to create a config that is tolerant of your style.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With