chomp?

Discussion in 'Python' started by Matt Herzog, Oct 17, 2008.

  1. Matt Herzog

    Matt Herzog Guest

    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)

    --
    "'My country, right or wrong,' is a thing that no patriot would think of saying. It is like saying, 'My mother, drunk or sober.'"

    -- G.K. Chesterton
     
    Matt Herzog, Oct 17, 2008
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron Powell
    Replies:
    0
    Views:
    1,343
    Aaron Powell
    Jul 24, 2003
  2. Matt Taylor

    Question on Chomp

    Matt Taylor, Sep 29, 2003, in forum: Perl
    Replies:
    2
    Views:
    508
    Matt Taylor
    Sep 29, 2003
  3. Fernando Armenta

    How you chomp in python

    Fernando Armenta, Sep 20, 2003, in forum: Python
    Replies:
    3
    Views:
    8,819
  4. lnatz

    equivalent of chomp in perl

    lnatz, Nov 3, 2006, in forum: C Programming
    Replies:
    35
    Views:
    948
    Keith Thompson
    Nov 5, 2006
  5. Larry

    chomp on a string

    Larry, Jan 18, 2010, in forum: C++
    Replies:
    7
    Views:
    3,480
    Richard
    Jan 18, 2010
  6. Emmanuel Touzery

    why won't ruby chomp for me?

    Emmanuel Touzery, Jan 29, 2004, in forum: Ruby
    Replies:
    7
    Views:
    387
    Ara.T.Howard
    Jan 30, 2004
  7. Replies:
    6
    Views:
    273
    Guillaume Benny
    Mar 29, 2006
  8. martin
    Replies:
    3
    Views:
    315
    Joe Smith
    Apr 15, 2006
Loading...