Re: How you chomp in python

Discussion in 'Python' started by Jeremy Dillworth, Sep 20, 2003.

  1. Strings in Python are immutable.

    Any time you perform an operation that seems like it might change a string,
    what really happens is a new string is returned.

    this:
    string.rstrip(build_number)

    returns your chomped string, but it's not being assigned to anything. 'Poor
    thing never had a chance ... :)

    You probably want:

    build_number = string.rstrip(build_number)

    or the more preferred way:

    build_number = build_number.rstrip()



    On Friday 19 September 2003 9:43 pm, Fernando Armenta wrote:
    > How you cut off the ^M at the end of a line? rstrip is not working.
    >
    >
    >
    > string.rstrip(build_number)
    >
    >
    >
    > thanks,
    >
    >
    >
    > -F
    Jeremy Dillworth, Sep 20, 2003
    #1
    1. Advertising

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,196
    Aaron Powell
    Jul 24, 2003
  2. Matt Taylor

    Question on Chomp

    Matt Taylor, Sep 29, 2003, in forum: Perl
    Replies:
    2
    Views:
    379
    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,553
  4. Stedwick
    Replies:
    3
    Views:
    100
    Stedwick
    Feb 14, 2008
  5. martin
    Replies:
    3
    Views:
    177
    Joe Smith
    Apr 15, 2006
Loading...

Share This Page