On Mon, 14 Nov 2022 at 18:00, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
>
> On 14/11/22 3:13 pm, MRAB wrote:
> > But if it's an expression where it's expecting a statement and it's not
> > a call, then it's probably a bug.
>
> The key word there is "probably". If there's any chance it
> could be not a bug, it can't be an error. At most it should
> be a warning, and that's what linters are for. I wouldn't
> like the core interpreter to be producing a bunch of warnings
> for things like this.
>

Notably, linters can be taught about more complex idioms, like:

try:
    raw_input
except NameError:
    raw_input = input

which is an easy way to make polyglot Py2/Py3 code that handles the
presence/absence of a particular name. Or, similarly:

try:
    os.sendfile
except AttributeError:
    ... # cope with sendfile not being available

When os.sendfile exists, it's a completely useless expression. When it
doesn't, it's an error. But the difference between those two is
crucial.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to