473,395 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Possible to have multiple loop variables?

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?

Thanks, - Dave
Jul 30 '08 #1
1 969
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
Jul 30 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: darin dimitrov | last post by:
Hello, I need help with an algoritm that given a set of "n" distinct numbers will generate all the possible permutations of fixed length "m" of these numbers WITH repetitions (a total of n^m...
2
by: Thall | last post by:
Hey Gurus - I've seen a few solutions to this problem, but none of which I can do without a little help. Here's the situation The following code loops thru a sales report, using the sales rep ID...
4
neo008
by: neo008 | last post by:
Hi all, Finally gave up and putting it here. I am new to visual basic stucked up with an error- Run time errors.'-2147217887 (8004021)': Multiple-step operation generated errors. check each...
2
by: Idrisu | last post by:
Hello, i have this constellation on tables in my database: Table A id|content Table B table_a_id|table_c_id
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.