Get list of attributes from list of objects?
Ian Pilcher
arequipeno at gmail.com
Wed Aug 2 14:41:09 EDT 2017
On 08/02/2017 12:49 PM, Chris Angelico wrote:
> On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher <arequipeno at gmail.com> wrote:
> You can't eliminate the loop, but you can compact it into a single
> logical operation:
>
> namelist = [foo.name for foo in foolist]
>
> That's a "list comprehension", and is an elegant way to process a list
> in various ways.
Very nice! Thank you!
--
========================================================================
Ian Pilcher arequipeno at gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================
More information about the Python-list
mailing list