Sujet : Re: get_used_memory
De : jon+usenet (at) *nospam* unequivocal.eu (Jon Ribbens)
Groupes : comp.lang.pythonDate : 13. Jun 2026, 23:53:48
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrn112rnrs.5fs.jon+usenet@raven.unequivocal.eu>
References : 1 2 3 4 5 6 7 8
User-Agent : slrn/1.0.3 (Linux)
On 2026-06-13, Paul Rubin <
no.email@nospam.invalid> wrote:
Jon Ribbens <jon+usenet@unequivocal.eu> writes:
Lawrence's version used your neat dict(line.split()[:2] ...) trick.
>
Maybe this:
>
dict((a,int(b)) for a,b in (x.split()[:2] for x in xs))
>
I feel like there should be a way to do this with the := operator
instead of the nested generators, but it doesn't seem to be there.
That was the way my version did it? If I use abbreviated variable names
like your version, it's actually shorter than yours ;-)
{e[0][:-1]: int(e[1]) for x in xs if (e := x.split())}
Haut de la page
Les messages affichés proviennent d'usenet.
NewsPortal