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: l.go...@trojmiasto.pl
Tel. 058 321 95 65 Kom.
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:
in...@trojmiasto.pl
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