messed up RE....i think

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick C
    New Member
    • Apr 2007
    • 54

    messed up RE....i think

    So I'm trying to just write a script that checks to see the national debt every minute for 3 minutes. (the time and duration is completely variable, im making up these tests for me to learn on)...

    So the script I have, which I've written by cutting and pasting from previous questions i've had answered and from what i've found on python.org, yields "None," rather than 3 gigantic debt figures.

    Can someone help me (i'm using Windows XP on python 2.5) find where I've gone arwy...
    thanks a lot...

    PC

    Code:
    >>> def debtcheck():
    ... 	webpage = urllib2.urlopen('http://www.brillig.com/debt_clock/')
    ... 	results2 = webpage.read()
    ... 	total_debt = re.compile('<TR><TD ALIGN=center><IMG SRC="debtiv.gif" WIDTH=399 HEIGHT=41 ALT=(.*?)</TD>',re.M|re.DOTALL)
    ... 	debt_data = total_debt.findall(results)
    ... 	
    >>> import sched, time
    >>> s=sched.scheduler(time.time, time.sleep)
    >>> def print_debt():
    ... 	s.enter(5, 1, debtcheck, ())
    ... 	s.enter(65, 1, debtcheck, ())
    ... 	s.enter(125, 1, debtcheck, ())
    ... 	s.run()
    ... 	
    
    >>> def print_debt():
    ... 	s.enter(5, 1, debtcheck, ())
    ... 	s.enter(65, 1, debtcheck, ())
    ... 	s.enter(125, 1, debtcheck, ())
    ... 	s.run()
    ... 
    >>> print print_debt()
    None
  • ghostdog74
    Recognized Expert Contributor
    • Apr 2006
    • 511

    #2
    Originally posted by Patrick C
    So I'm trying to just write a script that checks to see the national debt every minute for 3 minutes. (the time and duration is completely variable, im making up these tests for me to learn on)...

    So the script I have, which I've written by cutting and pasting from previous questions i've had answered and from what i've found on python.org, yields "None," rather than 3 gigantic debt figures.

    Can someone help me (i'm using Windows XP on python 2.5) find where I've gone arwy...
    thanks a lot...

    PC

    Code:
    >>> def debtcheck():
    ... 	webpage = urllib2.urlopen('http://www.brillig.com/debt_clock/')
    ... 	results2 = webpage.read()
    ... 	total_debt = re.compile('<TR><TD ALIGN=center><IMG SRC="debtiv.gif" WIDTH=399 HEIGHT=41 ALT=(.*?)</TD>',re.M|re.DOTALL)
    ... 	debt_data = total_debt.findall(results)
    ... 	
    >>> import sched, time
    >>> s=sched.scheduler(time.time, time.sleep)
    >>> def print_debt():
    ... 	s.enter(5, 1, debtcheck, ())
    ... 	s.enter(65, 1, debtcheck, ())
    ... 	s.enter(125, 1, debtcheck, ())
    ... 	s.run()
    ... 	
    
    >>> def print_debt():
    ... 	s.enter(5, 1, debtcheck, ())
    ... 	s.enter(65, 1, debtcheck, ())
    ... 	s.enter(125, 1, debtcheck, ())
    ... 	s.run()
    ... 
    >>> print print_debt()
    None
    first look, you did not return any values in your debtcheck() function that's why you have None.. return debt_data in that function, and i think it should be fine.

    Comment

    Working...