[Python-Dev] ACCEPTED: PEP 285

Neal Norwitz neal at metaslash.com
Wed Apr 3 21:05:21 EST 2002


"Delaney, Timothy" wrote:
> 
> test.py:6: Comparisons with [TRUE|True|true] may give incorrect results
>                    ^ extra i ;)
> test.py:7: Comparisons with [FALSE|False|false] may give incorrect results
>                    ^ extra i ;)

Already caught and fixed. :-)

> and would also add a warning for code in 2.3+ for code like
> 
> TRUE = <something>
> FALSE = <something>
> true = <something>
> false = <something>
> 
> test.py:2: TRUE appears to be a boolean constant - builtin True should be
> used.
> test.py:3: FALSE appears to be a boolean constant - builtin False should be
> used.
> test.py:4: true appears to be a boolean constant - builtin True should be
> used.
> test.py:5: false appears to be a boolean constant - builtin False should be
> used.

This is already done, but not in the example.  pychecker will even
bitch about tRuE, since the code always normalizes, then checks.
It was easier than writing all the cases, and I'm lazy.

Should not assign to true, it is similar to builtin True
Same for comparisons (or comparisions :-).

The error messages probably should be improved.
The check should be available in any version, since part 
of pychecker's purpose is to help with upgrades,
finding problems before upgrading.

After everything settles out with booleans, it would be good
to revisit this and other issues as they arise.
(So remind me later or submit a bug on SF.)

Neal



More information about the Python-list mailing list