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

Jon Ribbens jon+usenet at unequivocal.eu
Sun Nov 13 20:21:57 EST 2022


On 2022-11-14, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> On 14/11/22 1:31 pm, Jon Ribbens wrote:
>> On 2022-11-13, DFS <nospam at dfs.com> wrote:
>>> But why is it allowed in the first place?
>> 
>> Because it's an expression, and you're allowed to execute expressions.
>
> To put it a bit more clearly, you're allowed to evaluate
> an expression and ignore the result.

... because it may have side effects, and it's not possible to determine
whether it will or not in advance.


More information about the Python-list mailing list