compare items in list to x

2008-11-02 Thread Matt Herzog
I want a program that loops over a list of numbers (y) and tells me whether each number in the list is less than, greater than or equal to another number (x). In the below code, I can't get python to see that 2 is equal to 2. x = 2 def compare(): for y in ['12', '33', '2']: if x

chomp?

2008-10-17 Thread Matt Herzog
Hey Pythons. This script works fine except I would like it to NOT print everything on a newline. How can I tell print to chomp? Thanks. --- snip - #!/usr/bin/python import time import sys def getload(): f = open('/p

Python book question

2008-05-16 Thread Matt Herzog
People keep telling me I need a course in "Data Structures and Algorithms." Since Python is the only language that doesn't give me headaches I thought this book might be good. Has anyone read it or can anyone recommend the author? Can anyone recommend a better Data Structures and Algorithms book

replacing text inplace

2008-04-20 Thread Matt Herzog
Hey All. I'm learning some python with the seemingly simple task of updating a firewall config file with the new IP address when my dhcpd server hands one out. Yeah, I know it's dangerous to edit such a file "in place" but this is just an exercise at this point. I would not mind using file han

socket.AF_INET

2008-04-19 Thread Matt Herzog
Hi All. I'm trying to write a script that will send me an email message when my IP address changes on a specific NIC. On Linux, the script works. On FreeBSD, it fails with: Traceback (most recent call last): File "./pyifcheck.py", line 22, in if get_ip_address('xl0') == IPADDY: File "./pyifch