Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

osdsb Group Title

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

  • one year ago
  • one year ago

  • This Question is Closed
  1. RoamingBlue Group Title
    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.

    • one year ago
  2. osdsb Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    http://dpaste.com/787379/

    • one year ago
  3. RoamingBlue Group Title
    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

    • one year ago
  4. osdsb Group Title
    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.

    • one year ago
  5. osdsb Group Title
    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.

    • one year ago
  6. RoamingBlue Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    Awesome :)

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.