Hi,

I need to create a nested loop referencing a variable from the outer loop.
Basically something along the lines of:

hosts = [{'name': 'first', 'limit': 3}, {'name': 'second', 'limit': 5}]
for host in hosts:
    for i in range(1, host['limit'] + 1):
        print('%s-%d' % (host['name'], i))

For all I see it's not quite possible using with_nested or with_subelements
(how do I refer to the item coming from the first loop?). I cannot
enumerate all the items, they are simple int values, but their numer may be
quite large.

Is there something to the built-in loops I am missing which could possibly
help me using range() with limit coming from a dictionary from the first
loop/data set?

Thanks in advance for any tips.

-- 
*Łukasz Górski*
Administrator Systemu Linux
e-mail: [email protected]
Tel. 058 321 95 65 Kom. <http://trojmiasto.pl>
Moje miasto to Trójmiasto!
------------------------------
Trojmiasto.pl Sp. z o.o. ul. Wały Piastowskie 1, 80-855 Gdańsk
tel: 58 321-95-00 fax: 58 321-95-13 e-mail: [email protected]
NIP 583-30-12-490, REGON 220563678
Sąd Rejonowy Gdańsk-Północ w Gdańsku, VII Wydział Gospodarczy Krajowego
Rejestru Sądowego, KRS 0000300002, Kapitał zakładowy 2 150 000 PLN
[image: fb] <http://www.facebook.com/trojmiastopl> Trojmiasto.pl na
Facebooku. Dołącz do nas! <http://www.facebook.com/trojmiastopl>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEpJg8n%2BE7NT9F-vooEyi3t%3D2AueiJxwQUhXy1p14K_jOXUN1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to