chomp?

M

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('/proc/loadavg')
data = f.readline()
f.close()
(load1, load2, load3, extra) = data.split(' ',3)
return float(load1)

done = False
while not done:
while getload() < 3:
print getload()
time.sleep(3)

# we left the loop!
print "Ouch! My CPUs are roasting!
time.sleep(3)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top