On Mon, Jul 15, 2019 at 08:18:30AM -0700, Fabrizio Messina wrote:
> [
> price * (1 + vat)
> for
> item in basket
> if
> price is not None
> where
> price := item.get('price')
> vat := get_vat(item, user)
> ]
Since vat is only used once, we don't need a named variable for it:
[price * (1 + get_vat(item, user))
for item in basket
if (price:=item.get('price')) is not None
]
But if you insist in naming it:
[price * (1 + vat:= get_vat(item, user))
for item in basket
if (price:=item.get('price')) is not None
]
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/YZEHTMJHPZI3TWCHGNF2ZU5GVMCG4YIQ/
Code of Conduct: http://python.org/psf/codeofconduct/