[Python-ideas] Add "default" kwarg to list.pop()

Dan Sommers 2QdxY4RzWzUUiLuE at potatochowder.com
Fri Nov 2 08:38:04 EDT 2018


On 11/2/18 7:39 AM, Anders Hovmöller wrote:>
 >> So far, I count 12 people who responded to the original post by
 >> Giampaolo. By my count, I see:
 >>
 >> * five people in favour;
 >> * three people against, or see no need for it;
 >> * four people I can't tell if they are for or against,
 >>   (possibly neutral?) [1]
 >
 > For the little it's worth I'm +1 too. This seems like an obvious 
little improvement.

I'm having a hard time seeing a real use case.  Giampaolo's original
post contains this link:

https://github.com/giampaolo/psutil/blob/d8b05151e65f9348aff9b58da977abd8cacb2127/psutil/_pslinux.py#L1068

Yuck (from an aesthetics standpoint, not a functional standpoint).  :-)

There's an impedance mismatch between the data, which is structured and
has changed apparently arbitrarily between Linux releases, and the
return value of string.split, which is an ordered collection.  This code
effectively hides that mismatch and yields Python tuples, which
represent structured data.

I can certainly see the desire for a simpler solution (for some
definition of simpler), but how would adding a default parameter to
list.pop make this code any simpler?

Dan


More information about the Python-ideas mailing list