Possible to have multiple loop variables?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed Jul 30 14:02:20 EDT 2008
On Wed, 30 Jul 2008 10:49:58 -0700, laredotornado wrote:
> I don't know why I thought this would work, but I would like to have 3
> variables in my for loop per iteration. Those familiar will know that
> this
>
> ms1 = {'managed1':7019:8020,'managed2':7020:8021} for m, lp, ssl_lp in
> ms1.items():
> managedServer = create(m,'Server')
> print 'creating managed server '+m
> managedServer.setListenAddress('147.191.71.70')
> managedServer.setListenPort(lp)
> managedServer.setEnabled(0)
> cd('SSL/cgServer')
> managedServer.setEnabled(1)
> managedServer.setListenPort(ssl_lp)
> managedServer.setCluster(clus1)
>
> causes
>
> File "/export/third-party/etsbea/home/etsbea/tests/wlst/
> createcluster.py", line 9
> ms1 = {'managed1':7019:8020,'managed2':7020:8021}
> ^
> SyntaxError: invalid syntax
>
>
> How would I set up the ms1 array such that I can use three items per
> object?
`ms1` is a dictionary and not an array. You could use a tuple as value:
In [5]: ms1 = {'managed1': (7019, 8020), 'managed2': (7020, 8021)}
In [6]: for a, (b, c) in ms1.iteritems():
...: print a, b, c
...:
managed1 7019 8020
managed2 7020 8021
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list