Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Trimming a string

Reply
Thread Tools

Trimming a string

 
 
Double Dumbass on You
Guest
Posts: n/a
 
      08-02-2004
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? )


 
Reply With Quote
 
 
 
 
wes weston
Guest
Posts: n/a
 
      08-02-2004
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

 
Reply With Quote
 
 
 
 
Double Dumbass on You
Guest
Posts: n/a
 
      08-02-2004
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
>



 
Reply With Quote
 
Phil Frost
Guest
Posts: n/a
 
      08-02-2004
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

 
Reply With Quote
 
wes weston
Guest
Posts: n/a
 
      08-02-2004
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/...00000000000000
--------------------------------------------------------------------------------
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'

 
Reply With Quote
 
David Fraser
Guest
Posts: n/a
 
      08-06-2004
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
>>

>
>
>

 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      08-06-2004
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
 
Reply With Quote
 
Christopher T King
Guest
Posts: n/a
 
      08-06-2004
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 ).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trimming basic::string Mike Copeland C++ 7 04-19-2010 11:24 PM
Trimming some string using ruby Shekar Ls Ruby 8 08-06-2009 02:48 PM
String trimming throwing an exception Adrian C++ 5 04-12-2007 01:31 PM
Trimming leading and trailing spaces from a string Generic Usenet Account C++ 6 07-13-2005 12:02 AM
Re: Trimming Blank Spaces in String Steve C. Orr, MCSD ASP .Net 1 08-09-2003 12:46 AM



Advertisments