Custom Search

SUBSCRIBE

SUBSCRIBE : 300 + Free Video Tutorials Programming (Python, golang, Julia), DevOps

Monday, March 7, 2016

python itertools izip

https://github.com/openstack/ec2-api/blob/master/ec2api/api/cloud.py#L53

>>> import collections
>>>
>>> import itertools
>>>
>>> p1=['group_name', 'group_id', 'filter']
>>>
>>> p2=['security_group_strs','sg_ids', 'filter']
>>>
>>> collections.OrderedDict(itertools.izip(p1, p2))
OrderedDict([('group_name', 'security_group_strs'), ('group_id', 'sg_ids'), ('filter', 'filter')])



OR

>>>
>>> import six
>>>
>>>
>>> collections.OrderedDict(six.moves.zip(p1,p2))
OrderedDict([('group_name', 'security_group_strs'), ('group_id', 'sg_ids'), ('filter', 'filter')])
>>>




No comments:

Post a Comment