[Python-ideas] SyntaxWarning for for/while/else without break or return?
steve at pearwood.info
Fri Oct 9 04:28:09 CEST 2009
On Thu, 8 Oct 2009 08:59:21 pm Stefan Rank wrote:
> In the return-but-no-break-example I had in mind::
> def findit(bag):
> for elem in bag:
> if isgreat(elem):
> return elem
> return default
> the use of else, though correct and arguably readable, is still
We should raise UnnecessaryNotActuallyAnError then.
There is lots of code which is correct and readable while still
unnecessary. Should we ban these too?
flag = True and flag
if (flag is True) is True:
[item for item in seq if True]
alist.sort(key=lambda x: x)
and so forth. Just think, with a bit of imagination we can slow the
compiler down by a factor of two, three or even ten, by prohibiting all
sorts of perfectly legal code!
More information about the Python-ideas