In code, list.clear doesn't throw error - it's just ignored

Jon Ribbens jon+usenet at unequivocal.eu
Mon Nov 14 09:18:25 EST 2022


On 2022-11-14, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> Jon Ribbens <jon+usenet at unequivocal.eu> writes:
>>"""Create an array and print its length"""
>>array = [1, 2, 3]
>>array.clear
>
>   BTW: Above, there are /two/ expression statements
>   with no effect; the other one is
>
> """Create an array and print its length"""
>
>   . Apparently, linters know this and will not create
>   a warning for such string literals.

Not only do they know this, pylint will complain if you *don't* include
that line, which is why I included it ;-)


More information about the Python-list mailing list