473,382 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Trimming a string

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? )
Jul 18 '05 #1
7 1550
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

Jul 18 '05 #2
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 FUCK YOURSELF, it will be time well spent for you.

"wes weston" <ww*****@att.net> wrote in message
news:ek********************@bgtnsc05-news.ops.worldnet.att.net...
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

Jul 18 '05 #3
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 FUCK YOURSELF, it will be time well spent for you.

"wes weston" <ww*****@att.net> wrote in message
news:ek********************@bgtnsc05-news.ops.worldnet.att.net...
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

Jul 18 '05 #4
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 FUCK YOURSELF, it will be time well spent for you.

"wes weston" <ww*****@att.net> wrote in message
news:ek********************@bgtnsc05-news.ops.worldnet.att.net...
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'

Jul 18 '05 #5
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" <ww*****@att.net> wrote in message
news:ek********************@bgtnsc05-news.ops.worldnet.att.net...
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


Jul 18 '05 #6
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
Jul 18 '05 #7
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 ;)).

Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Generic Usenet Account | last post by:
I have worked out the following implementation for trimming the leading and trailing whitespace characters of a string (I am surprised not to see these as member functions). Am I doing it...
12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
13
by: john_g83 | last post by:
have a bit of c code that is ment to take a string (that may or may not have spaces before or after the string) i.e. " stuff ", and trims off the whitespace before and after. Code: char *trim...
7
by: GrandpaB | last post by:
I am comparing two strings for sorting. In some cases the string may be enclosed in quotes. Since the quote character is less than the A character, all the strings enclosed in quotes will finish...
8
by: rayw | last post by:
Following on from my post yesterday about nums -> binary strings ... I've written two routines that can trim the leading zeros from the results, so I call either of these like this: char *...
0
by: Paul | last post by:
On my local site, I have a folder that is security trimmed, so that only members of a Role can see it after they register and log on (I set the memberships). All works fine locally. However,...
5
by: Adrian | last post by:
Can this code ever throw out_of_range or should the commented out code always be used? Is there any chance that std::string::npos+1 is bigger then std::string::npos Take str to be any...
1
by: saldelmundo | last post by:
I'm a rookie with vb.net and I'm trying to modify source code that was given to me... in short the program I have is a file copy application... it reads a file name and path from a given txt file...
5
by: vinod allapu | last post by:
Hi all I have a string like this "2/6/1986" which is a date..Remember that it is a date actually..so day size and month size are variant..It is not always single digit or single character... I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.