Re: How can I make a program automatically run once per day?

2011-07-14 Thread monkeys paw
On 7/9/2011 10:01 PM, John Salerno wrote: Thanks everyone! I probably should have said something like "Python, if possible and efficient, otherwise any other method" ! :) I'll look into the Task Scheduler. Thanks again! You could use the below code. time.sleep(# seconds in a day) where i == 30

delete namespaces

2011-03-29 Thread monkeys paw
How do i delete a module namespace once it has been imported? I use import banner Then i make a modification to banner.py. When i import it again, the new changes are not reflected. Is there a global variable i can modify? -- http://mail.python.org/mailman/listinfo/python-list

file print extra spaces

2011-03-22 Thread monkeys paw
When i open a file in python, and then print the contents line by line, the printout has an extra blank line between each printed line (shown below): >>> f=open('authors.py') >>> i=0 >>> for line in f: print(line) i=i+1 if i > 14: break author_lis

os.utime

2011-03-20 Thread monkeys paw
I used os.uname to succesfully change the access and mod times of a file. My question is, is there any other date store for a file that indicates the creation time, or is it impossible to detect that a file with an older mod/access time is actually a 'new' file? os.utime('sum.py', (time.time(),ti

Re: class error

2011-03-18 Thread monkeys paw
On 3/18/2011 4:43 PM, Alexander Kapps wrote: On 18.03.2011 21:13, monkeys paw wrote: I have the following file: FileInfo.py: import UserDict After this import statement, the name "UserDict" refers to the module. class FileInfo(UserDict): Here you are trying to subclass the mo

class error

2011-03-18 Thread monkeys paw
I have the following file: FileInfo.py: import UserDict class FileInfo(UserDict): "store file metadata" def __init__(self, filename=None): UserDict.__init__(self) self["name"] = filename When i import it like so: import FileInfo i get this e

Re: auto increment

2011-03-04 Thread monkeys paw
On 3/4/2011 12:07 AM, Chris Rebert wrote: On Thu, Mar 3, 2011 at 9:05 PM, Dan Stromberg wrote: On Thu, Mar 3, 2011 at 8:48 PM, Chris Rebert wrote: On Thu, Mar 3, 2011 at 8:41 PM, monkeys paw wrote: Does python have an analogy to c/perl incrementer? e.g. i = 0 i++ i += 1 If you&#x

auto increment

2011-03-03 Thread monkeys paw
Does python have an analogy to c/perl incrementer? e.g. i = 0 i++ Thanks -- http://mail.python.org/mailman/listinfo/python-list

subclass urllib2

2011-02-28 Thread monkeys paw
I'm trying to subclass urllib2 in order to mask the version attribute. Here's what i'm using: import urllib2 class myURL(urllib2): def __init__(self): urllib2.__init__(self) self.version = 'firefox' I get this> Traceback (most recent call last): File "", line 1, in TypeEr

urlopen returns forbidden

2011-02-27 Thread monkeys paw
I have a working urlopen routine which opens a url, parses it for tags and prints out the links in the page. On some sites, wikipedia for instance, i get a HTTP error 403, forbidden. What is the difference in accessing the site through a web browser and opening/reading the URL with python urlli

pattern matching

2011-02-23 Thread monkeys paw
if I have a string such as '01/12/2011' and i want to reformat it as '20110112', how do i pull out the components of the string and reformat them into a DDMM format? I have: import re test = re.compile('\d\d\/') f = open('test.html') # This file contains the html dates for line in f:

Re: lambda with floats

2010-04-09 Thread monkeys paw
On 4/9/2010 2:40 PM, Patrick Maupin wrote: On Apr 9, 1:22 pm, monkeys paw wrote: On 4/9/2010 3:43 AM, Bas wrote: On Apr 7, 6:15 am, Patrick Maupinwrote: I should stop making a habit of responding to myself, BUT. This isn't quite an acre in square feet. I just saw the 43xxx and as

Re: lambda with floats

2010-04-09 Thread monkeys paw
On 4/9/2010 3:43 AM, Bas wrote: On Apr 7, 6:15 am, Patrick Maupin wrote: I should stop making a habit of responding to myself, BUT. This isn't quite an acre in square feet. I just saw the 43xxx and assumed it was, and then realized it couldn't be, because it wasn't divisible by 10. (I used t

Re: lambda with floats

2010-04-08 Thread monkeys paw
On 4/7/2010 12:15 AM, Patrick Maupin wrote: On Apr 6, 11:10 pm, Patrick Maupin wrote: On Apr 6, 11:04 pm, Patrick Maupin wrote: On Apr 6, 10:16 pm, monkeys paw wrote: I have the following acre meter which works for integers, how do i convert this to float? I tried return float

Re: lambda with floats

2010-04-08 Thread monkeys paw
On 4/8/2010 7:19 PM, Patrick Maupin wrote: On Apr 8, 6:06 pm, monkeys paw wrote: On 4/7/2010 1:08 PM, Peter Pearson wrote: On Tue, 06 Apr 2010 23:16:18 -0400, monkeys pawwrote: I have the following acre meter which works for integers, how do i convert this to float? I tried return

Re: lambda with floats

2010-04-08 Thread monkeys paw
On 4/7/2010 1:08 PM, Peter Pearson wrote: On Tue, 06 Apr 2010 23:16:18 -0400, monkeys paw wrote: I have the following acre meter which works for integers, how do i convert this to float? I tried return float ((208.0 * 208.0) * n) def s(n): ... return lambda x: (208 * 208) * n ... f

lambda with floats

2010-04-06 Thread monkeys paw
I have the following acre meter which works for integers, how do i convert this to float? I tried return float ((208.0 * 208.0) * n) >>> def s(n): ... return lambda x: (208 * 208) * n ... >>> f = s(1) >>> f(1) 43264 >>> 208 * 208 43264 >>> f(.25) 43264 -- http://mail.python.org/mailman/listi

reduce in loop

2010-04-04 Thread monkeys paw
Why does the following fail with the Traceback? def add(x,y): return x+y for rrr in range(1,20): reduce(add, range(1, r)) Traceback (most recent call last): File "", line 2, in TypeError: reduce() of empty sequence with no initial value -- http://mail.python.org/mailman/listinfo/pytho

Re: write to remote ile

2010-03-08 Thread monkeys paw
On 3/7/2010 9:53 PM, Martin P. Hellwig wrote: On 03/08/10 02:51, monkeys paw wrote: On 3/7/2010 9:20 PM, Martin P. Hellwig wrote: On 03/08/10 02:10, monkeys paw wrote: I can xfer a file from a remote server using: import urllib2 as u x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/tim

Re: write to remote ile

2010-03-07 Thread monkeys paw
On 3/7/2010 9:20 PM, Martin P. Hellwig wrote: On 03/08/10 02:10, monkeys paw wrote: I can xfer a file from a remote server using: import urllib2 as u x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl') for line in x: print line How can i write a file to the remote server

write to remote ile

2010-03-07 Thread monkeys paw
I can xfer a file from a remote server using: import urllib2 as u x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl') for line in x: print line How can i write a file to the remote server? I tried: x = u.url.open('http://joemoney.net/somefile.txt', 'w') but that does not work --

Re: python dowload

2010-02-23 Thread monkeys paw
On 2/23/2010 3:17 PM, Tim Chase wrote: monkeys paw wrote: I used the following code to download a PDF file, but the file was invalid after running the code, is there problem with the write operation? import urllib2 url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'

python dowload

2010-02-23 Thread monkeys paw
I used the following code to download a PDF file, but the file was invalid after running the code, is there problem with the write operation? import urllib2 url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf' a = open('adobe.pdf', 'w') for line in urllib2.urlopen(url): a.write(

new python install

2010-02-14 Thread monkeys paw
Upon invoking python, it hangs until Ctrl^C is typed, and then the >>> interactive shell begins. Like so: joemoney% python Python 2.4.6 (#1, Dec 13 2009, 23:45:11) [C] on sunos5 Type "help", "copyright", "credits" or "license" for more information. # Hangs ^^^ at this point until ^C is typed ^C

Re: Last M digits of expression A^N

2010-02-06 Thread monkeys paw
mukesh tiwari wrote: Hello everyone. I am kind of new to python so pardon me if i sound stupid. I have to find out the last M digits of expression.One thing i can do is (A**N)%M but my A and N are too large (10^100) and M is less than 10^5. The other approach was repeated squaring and taking

import data structure

2010-01-15 Thread monkeys paw
I want to store data in a file like show below. Then i want to import the data in, but am having trouble. I'm trying: import sfdata for x in author_list: print x FILE: sfdata.py (i'm trying to import it) == author_list = { '829337' : {

shell access

2010-01-11 Thread monkeys paw
How do you access the command line from the python interpreter? on unix: type python >>> print 'hey' 'hey' >>> # I want to access the shell here, how do i do that? -- http://mail.python.org/mailman/listinfo/python-list