Trimming a string

Discussion in 'Python' started by Double Dumbass on You, Aug 2, 2004.

  1. I have a string that is 7 characters and represents file mode in UNIX/LINUX
    from rpm:

    0100755

    I don't care about the 0100 portion, I am only interested in the file
    permissions portion which is 755. How can I get three characters from the
    string starting at the right? ( -OR- strip 4 characters from the left? )
     
    Double Dumbass on You, Aug 2, 2004
    #1
    1. Advertising

  2. Double Dumbass on You

    wes weston Guest

    Double Dumbass on You wrote:
    > I have a string that is 7 characters and represents file mode in UNIX/LINUX
    > from rpm:
    >
    > 0100755
    >
    > I don't care about the 0100 portion, I am only interested in the file
    > permissions portion which is 755. How can I get three characters from the
    > string starting at the right? ( -OR- strip 4 characters from the left? )
    >
    >

    DD,

    >>> x = "0100755"
    >>> print x[4:]

    755

    Reading the tutorial is really time well spent.
    wes
     
    wes weston, Aug 2, 2004
    #2
    1. Advertising

  3. Do you feel better about yourself for having posted a smug, shithead-type
    answer, troll??

    As a matter of fact, I was in a near fatal car wreck about 7 years ago.
    Suffered some brain damage. Now, I can't remember minute details such as
    that which I asked. I have read the python documentation numerous times.
    Sometimes, I just need a simple answer to a simple question, you simple
    cocksucker.

    GO **** YOURSELF, it will be time well spent for you.

    "wes weston" <> wrote in message
    news:ektPc.165630$...
    > Double Dumbass on You wrote:
    > > I have a string that is 7 characters and represents file mode in

    UNIX/LINUX
    > > from rpm:
    > >
    > > 0100755
    > >
    > > I don't care about the 0100 portion, I am only interested in the file
    > > permissions portion which is 755. How can I get three characters from

    the
    > > string starting at the right? ( -OR- strip 4 characters from the

    left? )
    > >
    > >

    > DD,
    >
    > >>> x = "0100755"
    > >>> print x[4:]

    > 755
    >
    > Reading the tutorial is really time well spent.
    > wes
    >
     
    Double Dumbass on You, Aug 2, 2004
    #3
  4. Double Dumbass on You

    Phil Frost Guest

    I couldn't agree more. The people on this list are total jerks and could
    use a real attitude adjustment. You might want to check out
    <http://www.php.net/>; the user commuinity there is one of the smartest
    and most helpful.

    On Mon, Aug 02, 2004 at 08:54:34AM -0700, Double Dumbass on You wrote:
    > Do you feel better about yourself for having posted a smug, shithead-type
    > answer, troll??
    >
    > As a matter of fact, I was in a near fatal car wreck about 7 years ago.
    > Suffered some brain damage. Now, I can't remember minute details such as
    > that which I asked. I have read the python documentation numerous times.
    > Sometimes, I just need a simple answer to a simple question, you simple
    > cocksucker.
    >
    > GO **** YOURSELF, it will be time well spent for you.
    >
    > "wes weston" <> wrote in message
    > news:ektPc.165630$...
    > > Double Dumbass on You wrote:
    > > > I have a string that is 7 characters and represents file mode in
    > > > UNIX/LINUX from rpm:
    > > >
    > > > 0100755
    > > >
    > > > I don't care about the 0100 portion, I am only interested in the
    > > > file permissions portion which is 755. How can I get three
    > > > characters from the string starting at the right? ( -OR- strip 4
    > > > characters from the left? )

    > >
    > >
    > > >>> x = "0100755"
    > > >>> print x[4:]

    > > 755
    > >
    > > Reading the tutorial is really time well spent.
    > >
    > > wes
     
    Phil Frost, Aug 2, 2004
    #4
  5. Double Dumbass on You

    wes weston Guest

    Double Dumbass on You wrote:
    > Do you feel better about yourself for having posted a smug, shithead-type
    > answer, troll??
    >
    > As a matter of fact, I was in a near fatal car wreck about 7 years ago.
    > Suffered some brain damage. Now, I can't remember minute details such as
    > that which I asked. I have read the python documentation numerous times.
    > Sometimes, I just need a simple answer to a simple question, you simple
    > cocksucker.
    >
    > GO **** YOURSELF, it will be time well spent for you.
    >
    > "wes weston" <> wrote in message
    > news:ektPc.165630$...
    >
    >>Double Dumbass on You wrote:
    >>
    >>>I have a string that is 7 characters and represents file mode in

    >
    > UNIX/LINUX
    >
    >>>from rpm:
    >>>
    >>>0100755
    >>>
    >>>I don't care about the 0100 portion, I am only interested in the file
    >>>permissions portion which is 755. How can I get three characters from

    >
    > the
    >
    >>>string starting at the right? ( -OR- strip 4 characters from the

    >
    > left? )
    >
    >>>

    >>DD,
    >>
    >> >>> x = "0100755"
    >> >>> print x[4:]

    >>755
    >>
    >> Reading the tutorial is really time well spent.
    >>wes
    >>

    >
    >
    >

    DD,
    I didn't mean to offend you; was trying to help.
    Here's the tutorial section on slicing where word is "HelpA".
    http://www.python.org/doc/2.3.4/tut/node5.html#SECTION005120000000000000000
    --------------------------------------------------------------------------------
    Strings can be subscripted (indexed); like in C, the first
    character of a string has subscript (index) 0. There is no
    separate character type; a character is simply a string of
    size one. Like in Icon, substrings can be specified with
    the slice notation: two indices separated by a colon.

    >>> word[4]

    'A'
    >>> word[0:2]

    'He'
    >>> word[2:4]

    'lp'

    Slice indices have useful defaults; an omitted first index
    defaults to zero, an omitted second index defaults to the
    size of the string being sliced.

    >>> word[:2] # The first two characters

    'He'
    >>> word[2:] # All but the first two characters

    'lpA'
     
    wes weston, Aug 2, 2004
    #5
  6. Double Dumbass on You

    David Fraser Guest

    Actually your answer was a bit ruder than his

    Double Dumbass on You wrote:
    > Do you feel better about yourself for having posted a smug, shithead-type
    > answer, troll??
    >
    > As a matter of fact, I was in a near fatal car wreck about 7 years ago.
    > Suffered some brain damage. Now, I can't remember minute details such as
    > that which I asked. I have read the python documentation numerous times.
    > Sometimes, I just need a simple answer to a simple question, you simple
    > *********.
    >
    > ***************, it will be time well spent for you.
    >
    > "wes weston" <> wrote in message
    > news:ektPc.165630$...
    >
    >>Double Dumbass on You wrote:
    >>
    >>>I have a string that is 7 characters and represents file mode in

    >
    > UNIX/LINUX
    >
    >>>from rpm:
    >>>
    >>>0100755
    >>>
    >>>I don't care about the 0100 portion, I am only interested in the file
    >>>permissions portion which is 755. How can I get three characters from

    >
    > the
    >
    >>>string starting at the right? ( -OR- strip 4 characters from the

    >
    > left? )
    >
    >>>

    >>DD,
    >>
    >> >>> x = "0100755"
    >> >>> print x[4:]

    >>755
    >>
    >> Reading the tutorial is really time well spent.
    >>wes
    >>

    >
    >
    >
     
    David Fraser, Aug 6, 2004
    #6
  7. Double Dumbass on You

    Peter Hansen Guest

    David Fraser wrote:

    > Double Dumbass on You wrote:
    >> "wes weston" wrote:
    >>> >>> x = "0100755"
    >>> >>> print x[4:]
    >>> 755
    >>> Reading the tutorial is really time well spent.

    >>
    >> Do you feel better about yourself for having posted a smug,
    >> shithead-type answer, troll??

    >
    > Actually your answer was a bit ruder than his


    And in fact, Wes' response was not in the least bit rude, but
    rather quite helpful in two important ways: giving the actual
    answer, and giving advice on how to find answers to similar
    questions in the future.

    Braindamagedness notwithstanding, Double Dumbass (appropriately
    named?) needs to learn to cope with his situation in life and
    reading the tutorial repeatedly, even, if necessary each time
    before posting a question, would be a better approach than
    insulting those who try to help.

    -Peter
     
    Peter Hansen, Aug 6, 2004
    #7
  8. On Fri, 6 Aug 2004, Peter Hansen wrote:

    > Braindamagedness notwithstanding, Double Dumbass (appropriately
    > named?) needs to learn to cope with his situation in life and
    > reading the tutorial repeatedly, even, if necessary each time
    > before posting a question, would be a better approach than
    > insulting those who try to help.


    He should take a page from the decorator debate - several hundred posts
    (possibly over a thousand), and not one direct insult hurled or flame war
    started (though I have been accused of insinuating others enganged in
    "dastardly" behaviour ;)).
     
    Christopher T King, Aug 6, 2004
    #8
    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. Steve C. Orr, MCSD

    Re: Trimming Blank Spaces in String

    Steve C. Orr, MCSD, Aug 9, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    477
  2. Generic Usenet Account

    Trimming leading and trailing spaces from a string

    Generic Usenet Account, Jul 8, 2005, in forum: C++
    Replies:
    6
    Views:
    396
    Paul Groke
    Jul 13, 2005
  3. Adrian
    Replies:
    5
    Views:
    483
    Adrian
    Apr 12, 2007
  4. Mike Copeland

    Trimming basic::string

    Mike Copeland, Apr 18, 2010, in forum: C++
    Replies:
    7
    Views:
    572
    Mike Copeland
    Apr 20, 2010
  5. Shekar Ls

    Trimming some string using ruby

    Shekar Ls, Aug 6, 2009, in forum: Ruby
    Replies:
    8
    Views:
    237
    Bertram Scharpf
    Aug 6, 2009
Loading...

Share This Page