Forum Discussion
Dec 07, 2010
Smart way to convert a PoolMemberDefinitionSequenceSequence to a IPPortDefinitionSequenceSequence
Hi,
I want to dump out (and eventually read in and set) the enabled state of each of my GTM pools pool members. Its easy to get a list of the pools and pool members, but the PoolMember.get_en...
L4L7_53191
Dec 09, 2010Nimbostratus
Have a look at 'list comprehensions'. They're extremely handy in situations like this. Think of them as an easy way to create a list from another iterable after you've manipulated it in some way. Similar to map(). So expanded, this:
[x.pool for x in data_list] translates to something like:
for x in data_list:
x.pool
but it returns a list of the returned items, not the items individually. That second comprehension is nested, and they'll bend your mind if you're coming into them new. I usually avoid nested comprehensions but for some reason it felt natural to do it in your case.
So you're dead right:the purpose of: [x.members for x in [y for y in data_list]] is to essentially get a the members attribute of the returned objects from get_member(). I needed a way to flatten out that list to nothing more than the pool members as defined by their IPPortDefinitions.
-Matt
-Matt
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects