On 09/26/2011 02:26 PM, Martin Gracik wrote:
I don't see any errors in here, but it took me a while to wrap my brain around it. I think in this particular case you would be better of with list comprehensions instead of map.
Thats why I used the map to make the extracting steps evident. I am not going to take over your entire function just some bits of it which I find most useful.
# create mapping from nics to their configurations config = collections.defaultdict(list) for nic, cfg in ip_params: config[nic].append(cfg)
This is a really cute idiom I wasn't aware of. We can use this in tens of places.
I use set() on ip_params in the beginning to make sure we don't have more of the same arguments, if this can happen here...
The passed in argument is a set already.
Also, as I see it, you don't need to strip the "ip=" because all the parameters in that list have it, and later you are prepending it again to all members.
Good point, this saves some lines and makes it look simpler.
So you can take this as an ACK to your solution, and this is just my suggestion to make the function a little bit simpler.
I'll push it with the tweaks suggested in your solution. Thanks for taking the time to inspect this in so much detail. Ales _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list