In code, list.clear doesn't throw error - it's just ignored
Cameron Simpson
cs at cskk.id.au
Mon Nov 14 21:33:40 EST 2022
On 14Nov2022 19:15, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> There is also the minor facet that "x.clear" can be bound to a
>different name...
>
>>>> x = [1, 2, 3.145926536, "Pie"]
>>>> clearx = x.clear
>>>> x
>[1, 2, 3.145926536, 'Pie']
>>>> clearx()
>>>> x
>[]
>>>>
I think the OP would take the stance that this:
clearx = x.clear
is more valid than:
x.clear
which discards the return value of the expression.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list