473,404 Members | 2,179 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,404 software developers and data experts.

Using for... for multiple lists

I am using the following code:

for i, f in filelist, self.checkbox:
if f.get():
print i

I am getting an error:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python23\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "install.py", line 123, in select_stage
for i, f in filelist, self.checkbox:
ValueError: unpack list of wrong size

Both filelist and self.checkbox are the same size (4 items btw). Is
there any way to get this done?

Thanks,

Harlin

Jul 18 '05 #1
4 1119
> Both filelist and self.checkbox are the same size (4 items btw). Is
there any way to get this done?


Use zip:

a, b = [1,2,3], ['a', 'b', 'c']
for i,j in zip(a,b):
print i,j

Or from itertools izip - which should be slightly more performant and less
memory consuming.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
On Sunday 06 March 2005 13:09, Harlin Seritt wrote:
for i, f in filelist, self.checkbox:
if f.get():
print i


Use:

for i, f in zip(filelist,self.checkbox):
<bla>

--
--- Heiko.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQBCKvUAf0bpgh6uVAMRAgqQAJ9LksE8xHaJCO6N+udbd+ kyrlsJ1gCdENTD
0yP3wmYLzbOAq2EI3BJniOE=
=53Rm
-----END PGP SIGNATURE-----

Jul 18 '05 #3
If sequences are not same length:

zip truncates to length of shortest input sequence

map(None, seq1, seq2) pads to length of longest seq.

(can't remember what itertools.izip() does)

Jul 18 '05 #4
Actually the sequences are of the same length. Forgot to mention that.

thanks,

Harlin

Jul 18 '05 #5

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

Similar topics

7
by: Felix Natter | last post by:
hi, I have a php-Script which gets passed a Boat-ID and this is used to mark an element in a <select> as the default: <select name="boote" multiple="multiple" size="5"> <option...
7
by: codeslayer | last post by:
Greetings to everyone in ‘forum-land': I have a problem that has plaguing me to no end. It is a CSS-related question, and I have not seen this question posted anywhere in forums or through...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
1
by: AndiSmith | last post by:
Hi guys, I wondered if anyone could help me with this problem, or even shed some light on the direction I need to take to resolve it? I'm using .NET 2.0 (C# flavor) to build a large user-based...
2
by: anchi.chen | last post by:
Hi People, Just wondering if any of you have ever come across any javascript examples that will allow one to drag and drop multiple items between lists? That is, users would be able to use the...
1
by: sarah_c_clough | last post by:
Hi, I have an application (written in C#.NET with the 2.0 framework and OpenGL) that runs several display lists. It's currently a little slow, so thought it would be a good idea to initialise...
3
by: DarkSoul | last post by:
I have multiple ArrayLists, could be 2 or 3 or 10 lists, with multiple values in them. Now what I need to do is to get a combination of all of them. For example, if I have 3 lists with the...
2
by: bsrcss | last post by:
I added a 3 column lists to my site using the techniques shown on http://www.communitymx.com/content/article.cfm?page=1&cid=27F87 I first tried their code by itself and it worked fine. When I...
3
by: saritha2008 | last post by:
Hi, As part of migrating bugs from JIRA to BugZilla, below is the requirement: If there are multiple “version” tags in my input.xml file For open bugs (Resolved,Reopened,Inprogress,NeedInfo) >...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.