Trimming a string

  • Thread starter Double Dumbass on You
  • Start date
D

Double Dumbass on You

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? )
 
W

wes weston

Double said:
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
 
D

Double Dumbass on You

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 said:
Double said:
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
 
P

Phil Frost

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.

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 said:
Double said:
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
 
W

wes weston

Double said:
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.

UNIX/LINUX

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'
 
D

David Fraser

Actually your answer was a bit ruder than his
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.

UNIX/LINUX

the

left? )
DD,

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

Reading the tutorial is really time well spent.
wes
 
P

Peter Hansen

David said:
Double said:
wes weston said:
>>> >>> 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
 
C

Christopher T King

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 ;)).
 

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,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top