Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

osdsb

  • 3 years ago

I've finished problem 10 in ps_5 and passed all the tests in the test harness, but when I run ps_5.py it doesn't return stories it just keeps looping printing "Polling"..."Sleeping"... I'm using WinXP and IDLE

  • This Question is Closed
  1. RoamingBlue
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Could you dpaste or pastebin your code, I'll take a look at it.

  2. osdsb
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://dpaste.com/787379/

  3. RoamingBlue
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    @osdsb I added (import pprint) at the top in the imports section so I could print out the stories object and see how it changed as it went through main() Then, commented out everything in the main function and started uncommenting a line at a time from the top, pprinting stories each time it changed: # Get stories from Google's Top Stories RSS news feed stories = process(" http://news.google.com/?output=rss ") pprint.pprint(stories) # Get stories from Yahoo's Top Stories RSS news feed stories.extend(process(" http://rss.news.yahoo.com/rss/topstories ")) pprint.pprint(stories) # Only select stories we're interested in stories = filter_stories(stories, triggerlist) pprint.pprint(stories) What I found is that after you run filter_stories, stories ends up empty ... everything gets filtered out of it, that's why you're not getting any output there. Your issue is in Part 3 Filtering Near the end of: def filter_stories(stories, triggerlist): If I comment out these two lines in the stories loop, it starts working: for story in stories: ## for trig in triggerlist: ## if trig.evaluate(story): filteredStories.append(story) return filteredStories

  4. osdsb
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hmm...interesting. You're right. But if I take those lines out then the test harness fails. http://dpaste.com/787422/ I'm stuck in my own real life programming loop! Thanks for the help, I'll see what I can do.

  5. osdsb
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok, i think my code is correct and working properly. None of the trigger words actually appear in the fields searched so all the entries were filtered out. I changed the search terms and it gave me results.

  6. RoamingBlue
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Awesome :)

  7. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy