Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6798245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:42:24+00:00 2026-05-26T18:42:24+00:00

Why does this: for i in reader: for j in empsTbl: if i[0] ==

  • 0

Why does this:

for i in reader:
        for j in empsTbl:
            if i[0] == j.inmptl_wiw_userid:
                print "Match"

print over 500 results

And this:

for i in empsTbl:
        for j in reader:
            if j[0] == i.inmptl_wiw_userid:
                print "Match"

print no results?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:42:25+00:00Added an answer on May 26, 2026 at 6:42 pm

    Looks like your reader is a generator, that can be read only once. Maybe a file reader?

    In the first case you read it only once and compare each value to all elements of empsTbl, which is apparently a list (or tuple or set or dict, i.e. can be read as much as you want).

    In the second case, you read it completely while being at the first item of empsTbl (apparently does not match it if nothing is printed) and then with the second item of empsTbl it cannot be read again (i.e. the file is read over).

    UPDATE: With this number of records you can copy everything into Python lists which can be iterated over and over (set/dictionary would be probably even better, as they offer you much faster lookup times)

    Maybe something like this:

    readerSet = set(i[0] for i in reader)
    
    for j in empsTbl:
        if j.inmptl_wiw_userid in readerSet:
            print "Match"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is that this does not work; while (reader.Read()) { if (reader.NextResult() ==
Ryan Bates' nifty_scaffolding, for example, does this edit.html.erb <%= render :partial => 'form' %>
I have a small app that has a Render thread. All this thread does
Does anybody know why the same code from this page http://emacsformacosx.com/ would not render
Does this pattern: setTimeout(function(){ // do stuff }, 0); Actually return control to the
Does this look like it should work? I'm wanting to generate directions from one
Does this smell? I have a few properties you can only set once. They
Does this code cause a memory leak: int main(){ int * a = new
Does this seem right, the dataFilePath is on disk and contains the right data,
Why does this javascript return 108 instead of 2008? it gets the day and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.