473,836 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I'm not getting data to print out

54 New Member
Greetings, i'm a total amateur using py 2.5 on Win XP...

I posted a similar message last week and I made the suggestion, yet I'm ending up with the same problem...

In my script after I ask it to print i get "None" WHY is that, what can I do to fix it?

here's my script

Expand|Select|Wrap|Line Numbers
  1. >>> import urllib2, sched, time, re
  2. >>> def debtcheck():
  3. ...     webpage = urllib2.urlopen('http://www.brillig.com/debt_clock/')
  4. ...     results = webpage.read()
  5. ...     total_debt = re.compile('<TR><TD ALIGN=center><IMG SRC="debtiv.gif" WIDTH=399 HEIGHT=41 ALT=(.*?)</TD>',re.M|re.DOTALL)
  6. ...     debt_data = total_debt.findall(results)
  7. ...     return debt_data
  8. ... 
  9. >>> s=sched.scheduler(time.time, time.sleep)
  10. >>> def print_debt():
  11. ...     s.enter(5, 1, debtcheck, ())
  12. ...     s.enter(35, 1, debtcheck, ())
  13. ...     s.enter(65, 1, debtcheck, ())
  14. ...     s.run()
  15. ...     
  16. >>> print print_debt()
  17. None
  18.  
  19.  
Apr 24 '07 #1
1 1147
ilikepython
844 Recognized Expert Contributor
Greetings, i'm a total amateur using py 2.5 on Win XP...

I posted a similar message last week and I made the suggestion, yet I'm ending up with the same problem...

In my script after I ask it to print i get "None" WHY is that, what can I do to fix it?

here's my script

Expand|Select|Wrap|Line Numbers
  1. >>> import urllib2, sched, time, re
  2. >>> def debtcheck():
  3. ...     webpage = urllib2.urlopen('http://www.brillig.com/debt_clock/')
  4. ...     results = webpage.read()
  5. ...     total_debt = re.compile('<TR><TD ALIGN=center><IMG SRC="debtiv.gif" WIDTH=399 HEIGHT=41 ALT=(.*?)</TD>',re.M|re.DOTALL)
  6. ...     debt_data = total_debt.findall(results)
  7. ...     return debt_data
  8. ... 
  9. >>> s=sched.scheduler(time.time, time.sleep)
  10. >>> def print_debt():
  11. ...     s.enter(5, 1, debtcheck, ())
  12. ...     s.enter(35, 1, debtcheck, ())
  13. ...     s.enter(65, 1, debtcheck, ())
  14. ...     s.run()
  15. ...     
  16. >>> print print_debt()
  17. None
  18.  
  19.  
It is because you didn't return anything from print_debt(). Instead of return debt_data in debtcheck you can put print debt_data or store it in a file, whichever is more convenient for you. There might be a better way though because I'm not that into the sched module.
Apr 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
6130
by: Jason | last post by:
hello, i am new to PHP, so go easy. I am using the examples in the book: PHP: Your Visual Blueprint For Creating Open Source, Server Side Content In the section where they talk about getting values from a form submission, the book says:
17
4699
by: John Hunter | last post by:
I have a largish data set (1000 observations x 100 floating point variables), and some of the of the data are missing. I want to try a variety of clustering, neural network, etc, algorithms on the data, and to keep life simple I want to reduce the dimensions of the matrix so that I have no missing values, since not all the algorithms are able to handle them and there is sufficient redundancy in the variables that I can afford to lose...
0
2246
by: anuradha.k.r | last post by:
hi, i have written a simple socket program in python to connect to a windows machine.On the server side i am running a windows socket program which works perfectly fine,my server program waites at accept() for a connection to be established.on the client side however i am not able to connect and am getting an error "10061 connection refused".the code was directly downloaded from sites. here is the code for client side: import socket
2
9604
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A, while an instance of class C should be able to check all methods #defined in C, B and A. #------------------------------------------------
9
3703
by: Ksenia Marasanova | last post by:
Hi, I have a little problem with encoding. Was hoping maybe anyone can help me to solve it. There is some amount of data in a database (PG) that must be inserted into Excel sheet and emailed. Nothing special, everything works. Except that non-ascii characters are not displayed properly. The data is stored as XML into a text field. When I use pgsql it's displayed good in the terminal. Now I run my script and print data
5
1710
by: David Bear | last post by:
Let's say I have a list called, alist. If I pass alist to a function, how can I get the name of it? alist = range(10) def afunction(list): listName = list.__name__ (fails for a list object)
11
1929
by: Ray Muforosky | last post by:
I have this: ------------ print "<FORM name=\"form3\" ACTION=\"cmdlog_rep.php\">\n"; print "<TD><INPUT TYPE=\"submit\" VALUE=\"Submit\"></TD>\n"; .. print "<INPUT type=\"HIDDEN\" name=\"year1\" >\n"; print "<INPUT type=\"TEXT\" name=\"when\" >\n"; print "</FORM>\n";
8
6525
by: cypher543 | last post by:
This has been driving me insane for the last hour or so. I have search everywhere, and nothing works. I am trying to use the subprocess module to run a program and get its output line by line. But, it always waits for the process to terminate and then return the output all at once. Can someone please show me some code that actually works for this sort of thing? It doesn't even have to use the subprocess module. Don't worry if the code...
5
5750
by: olaamussah | last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this out. Corrections would be highly appreciated. The code: use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; $CGI::POST_MAX = 1024 * 1000; sub print_login_form($);
0
1022
by: Heshan Suri | last post by:
Hi, I have written a the following python code to analyse a function or a method. I am having a script which is having a python function (add) and a class (MyClass) with a method (multiply).When I analyse it using the following method(analyze_func) , I get an output like below. The problem I am having is, I need to get the value 'MyClass.multiply' from the obj. When I do obj.__name__ , I am only getting "multiply" only.So can anyone...
0
9810
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10526
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10567
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10237
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7771
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6972
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5811
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4437
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3100
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.