[issue44513] for string methods strip, lstrip, rstrip, when param is a string which has more than one char, those methods is no useful currently

2021-06-25 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Dennis is correct: these are working as attended, you have just misunderstood 
what they are supposed to do.

--
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44513] for string methods strip, lstrip, rstrip, when param is a string which has more than one char, those methods is no useful currently

2021-06-25 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

This is the intended behavior. Use s.removeprefix() and s.removesuffix() 
instead.

--
nosy: +Dennis Sweeney

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44513] for string methods strip, lstrip, rstrip, when param is a string which has more than one char, those methods is no useful currently

2021-06-25 Thread redrose2100


New submission from redrose2100 :

for string methods strip, lstrip, rstrip, when param is a string which has more 
than 1 char, currently those methods remove char ,but not remove string , it is 
no useful

following is the results in python 3.9.5

Python 3.9.5 (default, May 18 2021, 14:42:02) [MSC v.1916 64 bit (AMD64)] :: 
Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> s="hellolloehb"
>>> print(s.lstrip("hello"))
b
>>> s="blloehhello"
>>> print(s.rstrip("hello"))
b
>>> s="helloehhollbllohhehello"
>>> print(s.strip("hello"))
b
>>>
In fact,
when s="hellolloehb" , s.lstrip("hello") expect to get "lloehb"
when s="blloehhello" , s.rstrip("hello") expect to get "blloeh"
when s="helloehhollbllohhehello" , s.strip("hello") expect to get 
"ehhollbllohhe"

--
components: Library (Lib)
messages: 396538
nosy: redrose2100
priority: normal
severity: normal
status: open
title: for string methods strip, lstrip, rstrip, when param is a string which 
has more than one char, those methods is no useful currently
type: behavior
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue44513>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42313] rstrip removes the trailing `e`s.

2020-11-10 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

For 3.9+, you could do exactly what you want with .removesuffix 
(/.removeprefix) methods;
>>> test = "external_e_object"
>>> test.removesuffix("_object")
'external_e'

--
nosy: +BTaskaya

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42313] rstrip removes the trailing `e`s.

2020-11-10 Thread Zachary Ware


Zachary Ware  added the comment:

See https://docs.python.org/3/library/stdtypes.html#str.rstrip

The `{l,r,}strip` methods remove all characters contained in the passed-in 
string; `"aabbccddeeffgg".rstrip("gfe") == "aabbccdd"`

--
nosy: +zach.ware
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue42313>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42313] rstrip removes the trailing `e`s.

2020-11-10 Thread Athul R


New submission from Athul R :

rstrip removes the trailing `e`s. 

i = "external_e_object"
i = i.rstrip('_object')
print(i) 
"""
It should have printed `external_e` but it prints only `external_`. 
"""

It happens only when I user rstrip("_object") not for other strings. 

# ===
# it works fine in the below case. 


i = "external_e_trail"
i = i.rstrip('_trail')
print(i) 
"""
It should have prints `external_e`
"""

--
components: Library (Lib)
files: python-bug.py
messages: 380678
nosy: Athul-R
priority: normal
severity: normal
status: open
title: rstrip removes the trailing `e`s.
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file49590/python-bug.py

___
Python tracker 
<https://bugs.python.org/issue42313>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5150] IDLE: add rstrip to Format menu

2020-06-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Adding rstrip as it was then was done over a decade ago, and this issue was 
closed then.  Improvements, as discussed immediately above have been added with 
other issues, or will be.  I am rejecting the add-on idea of incorporating 
reindent.py as unneeded.  (It should have been a new issue instead of 
re-opening this one.)

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
title: IDLE to support reindent.py -> IDLE: add rstrip to Format menu

___
Python tracker 
<https://bugs.python.org/issue5150>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39607] Add a parameter to strip, lstrip, and rstrip that treats the first parameter as a full string

2020-02-11 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

This has been discussed not long ago, it seems like it will need a PEP. See 
Brett's comment:

https://mail.python.org/archives/list/python-...@python.org/message/BDK6BDBOG2462SJIIOC5QMYPAJ5A4523/

and various discussions:

https://mail.python.org/archives/list/python-...@python.org/message/ZWRGCGANHGVDPP44VQKRIYOYX7LNVDVG/

https://mail.python.org/archives/list/python-id...@python.org/thread/RJARZSUKCXRJIP42Z2YBBAEN5XA7KEC3/#WIRID57ESUFUAQQQ6ZUY2RK5PKQQYSJ3

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39607] Add a parameter to strip, lstrip, and rstrip that treats the first parameter as a full string

2020-02-11 Thread Chris Rogers


New submission from Chris Rogers :

Consider this string:

'mailto:mailto:mailto:m...@example.com'

If you try to remove the mailtos with lstrip('mailto:'), you'll be left with 
this:

'n...@example.com'

That's because the three strip functions look at each character separately 
rather than as a whole string.

Currently, as a workaround, you have to either use regex or a loop. This can 
take several lines of code.

It would be great if the strip functions had a second parameter that lets you 
keep the first parameter intact.

You could then use this code to get the desired result:

'mailto:mailto:mailto:m...@example.com'.lstrip('mailto:', true)
>>m...@example.com

--
messages: 361791
nosy: Chris Rogers
priority: normal
severity: normal
status: open
title: Add a parameter to strip, lstrip, and rstrip that treats the first 
parameter as a full string
type: enhancement

___
Python tracker 
<https://bugs.python.org/issue39607>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2019-07-14 Thread Ulf Rompe


Change by Ulf Rompe :


--
pull_requests: +14569
pull_request: https://github.com/python/cpython/pull/14775

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2019-07-14 Thread Ulf Rompe


Change by Ulf Rompe :


--
pull_requests: +14564
pull_request: https://github.com/python/cpython/pull/14771

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2019-07-13 Thread Ulf Rompe


Ulf Rompe  added the comment:

Using a re.sub() call as documentation:

1. wouldn't be helpful for many developers. If they need to look up the 
documentation of a simple method they shouldn't be forced to learn about a more 
complex one as well to understand it.
2. would be wild guessing since the re module defines its own whitespace as 
well.

I have created a pull request that aligns the strip methods of bytearray to 
those of bytes objects. The implementation found there is cleaner and even a 
little bit faster.

Current master:

./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.lstrip()'
100 loops, best of 5: 245 nsec per loop
./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.rstrip()'
100 loops, best of 5: 245 nsec per loop
./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.strip()'
100 loops, best of 5: 260 nsec per loop

Using my patch:

./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.lstrip()'
100 loops, best of 5: 235 nsec per loop
./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.rstrip()'
100 loops, best of 5: 235 nsec per loop
./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.strip()'
100 loops, best of 5: 239 nsec per loop


I have also updated the documentation, adding "whitespace" to the glossary and 
linking to it from many places in the documentation of standard types.

--
nosy: +rompe

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2019-07-13 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
pull_requests: +14548
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/14753

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36410] Proposal to make strip/lstrip/rstrip more explicit

2019-03-23 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Generally, we don't make changes that would break existing code relying on the 
documented and tested behavior.

If you would like to propose a new method, the python-ideas mailing list would 
be a good place to start.

>>> s[len('mailto:'):] if s.startswith('mailto:') else s
'ma...@gmail.com'

--
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type: behavior -> enhancement
versions:  -Python 2.7, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36410] Proposal to make strip/lstrip/rstrip more explicit

2019-03-23 Thread Alex Grigoryev

Alex Grigoryev  added the comment:

https://docs.python.org/2/library/string.html#string.lstrip 
(https://link.getmailspring.com/link/4c83e422-2f29-440a-8ce3-0ae8b13f5...@getmailspring.com/0?redirect=https%3A%2F%2Fdocs.python.org%2F2%2Flibrary%2Fstring.html%23string.lstrip=cmVwb3J0QGJ1Z3MucHl0aG9uLm9yZw%3D%3D)
Here should be clarified better. Yes I think API for explicit behavior should 
be discussed, because the other way is this
In [1]: "ma...@gmail.com".split("mailto:;)[-1]
Out[1]: 'ma...@gmail.com'
In [2]: "maria@gmail.commailto:".split("mailto:;)[-1]
Out[2]: ''
On март 23 2019, at 10:39 вечера, Karthikeyan Singaravelan 
 wrote:
>
> Karthikeyan Singaravelan  added the comment:
> https://docs.python.org/3.8/library/stdtypes.html?highlight=lstrip#str.lstrip
> > Return a copy of the string with leading characters removed. The chars 
> > argument is a string specifying the set of characters to be removed. If 
> > omitted or None, the chars argument defaults to removing whitespace. The 
> > chars argument is not a prefix; rather, all combinations of its values are 
> > stripped:
> The last sentence talks about the report. In the given examples it strips all 
> the given characters in chars from left until it finds a character that is 
> not found as part of the given chars argument.
> In [2]: 'mailto:ma...@gmail.com'.lstrip('mailto:') # Stops at 'r' that 
> doesn't need to be stripped
> Out[2]: 'r...@gmail.com'
>
> In [3]: 'mailto:ma...@gmail.com'.lstrip('ailto:') # 'm' is the first 
> character and is not found in chars 'ailto:'
> Out[3]: 'mailto:ma...@gmail.com'
>
> Changing this would break a lot of old code and adding an API for two 
> different behaviors would require a larger discussion. Perhaps did you find 
> any part of docs that you would like to improve to clarify this better?
> --
> nosy: +xtreak
> versions: -Python 3.5, Python 3.6, Python 3.9
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36410] Proposal to make strip/lstrip/rstrip more explicit

2019-03-23 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

https://docs.python.org/3.8/library/stdtypes.html?highlight=lstrip#str.lstrip

> Return a copy of the string with leading characters removed. The chars 
> argument is a string specifying the set of characters to be removed. If 
> omitted or None, the chars argument defaults to removing whitespace. The 
> chars argument is not a prefix; rather, all combinations of its values are 
> stripped:

The last sentence talks about the report. In the given examples it strips all 
the given characters in chars from left until it finds a character that is not 
found as part of the given chars argument.

In [2]: 'mailto:ma...@gmail.com'.lstrip('mailto:') # Stops at 'r' that doesn't 
need to be stripped
Out[2]: 'r...@gmail.com'

In [3]: 'mailto:ma...@gmail.com'.lstrip('ailto:') # 'm' is the first character 
and is not found in chars 'ailto:'
Out[3]: 'mailto:ma...@gmail.com'

Changing this would break a lot of old code and adding an API for two different 
behaviors would require a larger discussion. Perhaps did you find any part of 
docs that you would like to improve to clarify this better?

--
nosy: +xtreak
versions:  -Python 3.5, Python 3.6, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36410] Proposal to make strip/lstrip/rstrip more explicit

2019-03-23 Thread Alex Grigoryev


New submission from Alex Grigoryev :

These methods have confusing implicit behavior. I propose to make it explicit, 
either strip the exact sequence or chars or leave the string as is.

In [1]: 'mailto:ma...@gmail.com'.lstrip('mailto')
Out[1]: ':ma...@gmail.com'

In [2]: 'mailto:ma...@gmail.com'.lstrip('mailto:')
Out[2]: 'r...@gmail.com'

In [3]: 'mailto:ma...@gmail.com'.lstrip('ailto:')
Out[3]: 'mailto:ma...@gmail.com'

--
messages: 338695
nosy: Alex Grigoryev
priority: normal
severity: normal
status: open
title: Proposal to make strip/lstrip/rstrip more explicit
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue36410>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-08-28 Thread Elliot Edmunds


Elliot Edmunds  added the comment:

Not sure how helpful it would be to have the re.sub expressions for lstrip and 
rstrip, but I think it would look like:

l_stripped = re.sub(r'^\s*', '', foo)
r_stripped = re.sub(r'\s*$', '', foo)

--
nosy: +Elliot Edmunds
Added file: https://bugs.python.org/file47769/whitespace_regex.py

___
Python tracker 
<https://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33904] IDLE: In rstrip, rename class RstripExtension as Rstrip

2018-06-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33904] IDLE: In rstrip, rename class RstripExtension as Rstrip

2018-06-20 Thread miss-islington


miss-islington  added the comment:


New changeset b41dc5682c596258d1489a1409fad2d65b5dffd9 by Miss Islington (bot) 
in branch '3.6':
bpo-33904:  In IDLE's rstrip, rename class RstripExtension as Rstrip (GH-7811)
https://github.com/python/cpython/commit/b41dc5682c596258d1489a1409fad2d65b5dffd9


--

___
Python tracker 
<https://bugs.python.org/issue33904>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33904] IDLE: In rstrip, rename class RstripExtension as Rstrip

2018-06-20 Thread miss-islington


miss-islington  added the comment:


New changeset b0f352680e73a374748994d383f591f2e4702669 by Miss Islington (bot) 
in branch '3.7':
bpo-33904:  In IDLE's rstrip, rename class RstripExtension as Rstrip (GH-7811)
https://github.com/python/cpython/commit/b0f352680e73a374748994d383f591f2e4702669


--
nosy: +miss-islington

___
Python tracker 
<https://bugs.python.org/issue33904>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33904] IDLE: In rstrip, rename class RstripExtension as Rstrip

2018-06-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7423

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33904] IDLE: In rstrip, rename class RstripExtension as Rstrip

2018-06-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7422

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33904] IDLE: In rstrip, rename class RstripExtension as Rstrip

2018-06-19 Thread Srinivas Reddy T


Change by Srinivas  Reddy T :


--
keywords: +patch
pull_requests: +7418
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33904] IDLE: In rstrip, rename class RstripExtension as Rstrip

2018-06-19 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
title: IDLE: In rstrip, change class RstripExtension to Rstrip -> IDLE: In 
rstrip, rename class RstripExtension as Rstrip

___
Python tracker 
<https://bugs.python.org/issue33904>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33904] IDLE: In rstrip, change class RstripExtension to Rstrip

2018-06-19 Thread Terry J. Reedy


New submission from Terry J. Reedy :

Rstrip is no longer an extension.  Change all occurrences throughout idlelib, 
including tests.  Some may not be covered in tests.  Branch after #33855 is 
merged.

--
assignee: terry.reedy
components: IDLE
messages: 320001
nosy: terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: IDLE: In rstrip, change class RstripExtension to Rstrip
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue33904>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-04-11 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> added the comment:

Slightly tangential, but it would be great if the documentation of lstrip() and 
rstrip() could include an equivalent definition in terms of re.sub(), e.g.:

lstrip(foo) == re.sub(r'(?u)\A\s*', '', foo)
rstrip(foo) == re.sub(r'(?u)\s*\Z', '', foo)

(Or whatever else is correct.)

--
nosy: +oulenz

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-03-31 Thread Jakub Wilk

Change by Jakub Wilk :


--
nosy: +jwilk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-03-31 Thread Nitish

Change by Nitish :


--
nosy: +nitishch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-03-30 Thread Dimitri Papadopoulos Orfanos

Dimitri Papadopoulos Orfanos <dimitri.papadopou...@gmail.com> added the comment:

I agree on avoiding a link to str.isspace() and defining "whitespace" instead.

However please note there are many de facto definitions of "whitespace". All of 
them must be documented - or at least the conceptual classes of "whitespace" 
and clarify which class each of the following belongs to:

* Unicode whitespaces are by very far the most common: str.isspace(), 
strip()/lstrip()/rstrip(), Py_UNICODE_ISSPACE.

* Py_ISSPACE targets byte/bytearray but is never used!

* bytearray.strip() does not use Py_ISSPACE but a hardcoded list of ASCII 
whitespaces instead.

* finally string.whitespace is probably equivalent to the list used by 
bytearray.strip().

Beyond the docs, I think Python 3 should rationalize bytearray.strip() /  
Py_ISSPACE / string.whitespace, probably having bytearray.strip() rely on 
Py_ISSPACE, and Py_ISSPACE rely on string.whitespace unless string.whitespace 
is obsoleted.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-03-29 Thread Joel Johnson

Joel Johnson <particlema...@gmail.com> added the comment:

I have started working on this and will have a pull request submitted by the 
end of the week. 

The term "whitespace" appears in several contextual situations throughout the 
documentation. While all situations would benefit from the definition of 
"whitespace" contained in the str.isspace() documentation, not all of the 
situations would benefit from a link to str.isspace() whose primary goal is to 
document the str.isspace() function and not to provide a global definition of 
what a whitespace character is.

Therefore I suggest the documentation of Python 3 create a new glossary 
definition of "whitespace" (which contains the definition currently in the 
str.isspace() documentation) and is pointed to wherever the term "whitespace" 
is used in any documentation related to strings - including this specific case 
of strip()/lstrip()/rstrip().

--
nosy: +joel.johnson

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-03-19 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
versions: +Python 3.7, Python 3.8 -Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26447] rstrip() is pilfering my 'p'

2016-02-26 Thread Eryk Sun

Changes by Eryk Sun :


--
stage:  -> resolved

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26447] rstrip() is pilfering my 'p'

2016-02-26 Thread Ethan Furman

Ethan Furman added the comment:

https://docs.python.org/3/library/stdtypes.html#str.strip
-
[...] The chars argument is not a prefix or suffix; rather, all combinations of 
its values are stripped:

--
nosy: +ethan.furman
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26447] rstrip() is pilfering my 'p'

2016-02-26 Thread Jerod “j3rd” Gawne

New submission from Jerod “j3rd” Gawne:

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit 
(AMD64)] on win32

In[4]: str = 'aaap.py'
In[5]: print(str.rstrip('.py'))
aaa

In[6]: str = 'aaap.pdf'
In[7]: print(str.rstrip('.pdf'))
aaa

In[8]: str = 'aaab.pdf'
In[9]: print(str.rstrip('.pdf'))
aaab

In[10]: str = 'apapapab.pdf'
In[11]: print(str.rstrip('.pdf'))
apapapab

In[12]: str = 'apapapap.pdf'
In[13]: print(str.rstrip('.pdf'))
apapapa

what's with the 'p' pilfering?

In[14]: str = 'apapapab.bdf'
In[15]: print(str.rstrip('.bdf'))
apapapa
In[16]: print(str.rstrip(r'.bdf'))
apapapa

In[18]: print(str.rstrip('\.bdf'))
apapapa

Actually though, it's grabbing an additional character before the '.' the same 
as the one after.

--
messages: 260908
nosy: Jerod “j3rd” Gawne
priority: normal
severity: normal
status: open
title: rstrip() is pilfering my 'p'
type: behavior
versions: Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26447>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2016-01-04 Thread Dimitri Papadopoulos Orfanos

Dimitri Papadopoulos Orfanos added the comment:

In Python 3 the situation is similar:
* The Py_UNICODE_ISSPACE macro is used internally to define str.isspace() and 
wherever Python needs to detect "whitespace" characters in strings.
* There is an equivalent function Py_ISSPACE for bytes/bytearray.
* The bytearray.strip() implementation for bytearray relies on hardcoded ASCII 
whitespaces instead of Py_ISSPACE.
* string.whitespace is a list of "ASCII whitespace characters" carved in stone. 
As far as I can see string.whitespace is defined but not used anywhere in 
Python source code.

Therefore I suggest the documentation of Python 3 points to str.isspace() 
wherever the term "whitespace" is used in any documentation related to strings 
- including this specific case of strip()/lstrip()/rstrip().

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2016-01-04 Thread Dimitri Papadopoulos Orfanos

Dimitri Papadopoulos Orfanos added the comment:

In Python 2, as far as I can understand, string.whitespace and str.isspace() 
are different:
* str.isspace() is built upon the C isspace() function and is therefore 
locale-dependant. Python heavily relies on isspace() to detect "whitespace" 
characters.
* string.whitespace is a list of "ASCII whitespace characters" carved in stone. 
As far as I can see string.whitespace is defined but not used anywhere in 
Python source code.

See source code:
* Modules/stringobject.c around line 3319:
  [...]
  string_isspace(PyStringObject *self)
  {
  [...]
  e = p + PyString_GET_SIZE(self);
  for (; p < e; p++) {
  if (!isspace(*p))
  return PyBool_FromLong(0);
  }
  return PyBool_FromLong(1);
  [...]
* Lib/string.py near line 23:
  whitespace = ' \t\n\r\v\f'

Functions strip()/lstrip()/rstrip() use str.isspace() and have nothing to do 
with string.whitespace:

* Modules/stringobject.c around line 1861:
[...]
do_strip(PyStringObject *self, int striptype)
{
[...]
i = 0;
if (striptype != RIGHTSTRIP) {
while (i < len && isspace(Py_CHARMASK(s[i]))) {
i++;
}
}
[...]

Therefore I suggest the documentation of Python 2.7 points to str.isspace() 
wherever the term "whitespace" is used in the documentation - including this 
specific case of strip()/lstrip()/rstrip().

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti
stage:  -> needs patch
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25433] whitespace in strip()/lstrip()/rstrip()

2015-10-18 Thread Dimitri Papadopoulos Orfanos

New submission from Dimitri Papadopoulos Orfanos:

The documentation of strip() / lstrip() / rstrip() should define "whitespace" 
more precisely.

The Python 3 documentation refers to "ASCII whitespace" for bytes.strip() / 
bytes.lstrip() / bytes.rstrip() and "whitespace" for str.strip() / str.lstrip() 
/ str.rstrip(). I suggest the following improvements:
* add a link from "ASCII whitespace" to string.whitespace or bytes.isspace(),
* define plain "whitespace" more precisely (possibly with a link to 
str.isspace()).

The Python 2 documentation refers to plain "whitespace". As far as I know 
strip() removes ASCII whitespaces only. If so, please:
* add a link to string.whitespace or str.isspace(),
* improve the string.whitespace documentation and explain that it is 
locale-dependent (see documentation of str.isspace()).

--
assignee: docs@python
components: Documentation
messages: 253152
nosy: Dimitri Papadopoulos Orfanos, docs@python
priority: normal
severity: normal
status: open
title: whitespace in strip()/lstrip()/rstrip()
type: enhancement
versions: Python 2.7, Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24445] rstrip strips what it doesn't have to

2015-06-13 Thread o1da

o1da added the comment:

Ok, thank you. I thought it trims whole sequence or nothing.

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24445
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24445] rstrip strips what it doesn't have to

2015-06-13 Thread Patrick Maupin

Patrick Maupin added the comment:

Example

 text = 'test1/1.jp2'
 text.rstrip('.2jp')
'test1/1'

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24445
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24445] rstrip strips what it doesn't have to

2015-06-13 Thread Patrick Maupin

Patrick Maupin added the comment:

I think you misunderstand rstrip -- it works from the right, and checks to see 
if the right-most character is in the string you have given it.  As long as it 
is, then it will remove the character and loop

--
nosy: +Patrick Maupin

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24445
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24445] rstrip strips what it doesn't have to

2015-06-13 Thread o1da

New submission from o1da:

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type help, copyright, credits or license for more information.
 text = 'test1/1.jp2'
 text.rstrip('.jp2')
'test1/1'
 text = 'test1.jp2'
 text.rstrip('.jp2')
'test1'
 text = 'test1/2.jp2'
 text.rstrip('.jp2')
'test1/'
 

Why the rstrip function stripped '2' from the last example? I think that it is 
a bug.

--
messages: 245311
nosy: o1da
priority: normal
severity: normal
status: open
title: rstrip strips what it doesn't have to
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24445
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24445] rstrip strips what it doesn't have to

2015-06-13 Thread Martin Panter

Martin Panter added the comment:

The 3.5 documentation of str.strip() was recently modified in Issue 24204 due 
to this kind of misunderstanding. Perhaps other versions should be modified as 
well, or the str.l/rstrip() methods, or the bytes() and bytearray() methods. 
See also Issue 23560 proposing to group the documentation of these methods 
together.

--
nosy: +vadmium

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24445
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: What is rstrip() in python?

2014-11-11 Thread Will Acheson
On Sunday, November 9, 2014 6:12:24 AM UTC-5, satish...@gmail.com wrote:
 What is rstrip() in python?
 
 What does it do in the following piece of code?
 
 import sqlite3
 conn = sqlite3.connect('dbase1')
 curs = conn.cursor()
 
 file = open('data.txt')
 rows = [line.rstrip().split(',') for line in file]

rstrip() removes whitespace, newline characters, tab characters, and carrige 
return characters (\n \t \r respectively) on the tail of a string.  

Or it can be used with an input parameter to remove all instances of that 
parameter from the tail of a string.

ex:
 stringy = i am helpful  \t\t\t\t\n\n  
 stringy = stringy.rstrip()
 print stringy

stdout: i am helpful

or:
 stringy = my favorite number is 80
 stringy = stringy.rstrip('0')
 print stringy

stdout: my favorite number is 8



pretty simple method, helpful for parsing out formatting characters from 
scraped content from webpages.
https://docs.python.org/2/library/stdtypes.html?highlight=rstrip#str.rstrip
-- 
https://mail.python.org/mailman/listinfo/python-list


What is rstrip() in python?

2014-11-09 Thread satishmlmlml
What is rstrip() in python?

What does it do in the following piece of code?

import sqlite3
conn = sqlite3.connect('dbase1')
curs = conn.cursor()

file = open('data.txt')
rows = [line.rstrip().split(',') for line in file]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is rstrip() in python?

2014-11-09 Thread Chris Angelico
On Sun, Nov 9, 2014 at 10:11 PM,  satishmlm...@gmail.com wrote:
 What is rstrip() in python?

 What does it do in the following piece of code?

 import sqlite3
 conn = sqlite3.connect('dbase1')
 curs = conn.cursor()

 file = open('data.txt')
 rows = [line.rstrip().split(',') for line in file]

Do you know what type of object 'line' is here? Do you know what you
get when you iterate over a file?

Get an object of that type in the interactive interpreter, maybe like this:

file = open('data.txt')
line = next(file)

Then you can find out about its methods:

help(line.rstrip)

That should tell you what you want to know.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is rstrip() in python?

2014-11-09 Thread Steven D'Aprano
satishmlm...@gmail.com wrote:

 What is rstrip() in python?

Have you read the Fine Manual?

Did you try googling first?

https://duckduckgo.com/html/?q=python+rstrip


 What does it do in the following piece of code?

It removes trailing whitespace.


 import sqlite3
 conn = sqlite3.connect('dbase1')
 curs = conn.cursor()
 
 file = open('data.txt')
 rows = [line.rstrip().split(',') for line in file]


-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is rstrip() in python?

2014-11-09 Thread Mark Lawrence

On 09/11/2014 11:11, satishmlm...@gmail.com wrote:

What is rstrip() in python?


It's a function or method call.



What does it do in the following piece of code?


I'm not actually sure.  Would you be kind enough to look it up in the 
documentation for me and let me know, thanks?




import sqlite3
conn = sqlite3.connect('dbase1')
curs = conn.cursor()

file = open('data.txt')
rows = [line.rstrip().split(',') for line in file]



--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: What is rstrip() in python?

2014-11-09 Thread Terry Reedy

On 11/9/2014 6:11 AM, satishmlm...@gmail.com wrote:

What is rstrip() in python?


The manuals have a rather complete index.  If 'rstrip' is missing from 
the index, let us know so we can fix it.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: What is rstrip() in python?

2014-11-09 Thread Joel Goldstick
On Sun, Nov 9, 2014 at 12:46 PM, Terry Reedy tjre...@udel.edu wrote:
 On 11/9/2014 6:11 AM, satishmlm...@gmail.com wrote:

 What is rstrip() in python?

google on 'rstrip python' gets this at first link:
https://docs.python.org/2/library/stdtypes.html#str.rstrip

google is your friend.


 The manuals have a rather complete index.  If 'rstrip' is missing from the
 index, let us know so we can fix it.

 --
 Terry Jan Reedy

 --
 https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue12444] accept sets or collections for str.strip/lstrip/rstrip

2011-06-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Agreed with Raymond.  Is there some way the doc could be improved, or do we 
just close this report?

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12444
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12444] accept sets or collections for str.strip/lstrip/rstrip

2011-06-30 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

The docs are clear on this topic.  No doc change can help someone who skips 
reading the docs and assumes the method does something different.

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12444
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12444] accept sets or collections for str.strip/lstrip/rstrip

2011-06-29 Thread Peter Eisentraut

New submission from Peter Eisentraut pete...@gmx.net:

It appears to be a pretty common mistake to think that the argument of 
str.strip/lstrip/rstrip is a substring rather than a set of characters.  To 
allow a more clearer notation, it would be nice if these functions also 
accepted an argument other than a string, for example a set or any collection.  
Then you could write, for example:

a.strip({'a', 'b', 'c'})

I suggest to either add support for sets specifically, or more generally 
anything that supports the in operator.

I can try to code it up if it sounds acceptable.

--
components: Library (Lib)
messages: 139449
nosy: petere
priority: normal
severity: normal
status: open
title: accept sets or collections for str.strip/lstrip/rstrip
type: feature request

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12444
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12444] accept sets or collections for str.strip/lstrip/rstrip

2011-06-29 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

-1 on complicating the API.  The purported problem isn't pervasive enough to 
warrant a change (I frequently teach python classes and do code reviews and 
rarely encounter this issue).  Also, the proposed change isn't going to help 
the people who are setting out to remove a .html suffix and are presuming 
that rstrip is the way to do it.  Those folks have already made an unfounded 
assumption this proposal does nothing to invalidate their experiment.  AFAICT, 
this proposal would only benefit someone who already knows that strip 
characters are accepted in all combinations (as clearly documented).

--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12444
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12444] accept sets or collections for str.strip/lstrip/rstrip

2011-06-29 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12444
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10406] IDLE 2.7 on OS X does not enable Rstrip extension by default

2010-12-07 Thread Ronald Oussoren

Ronald Oussoren ronaldousso...@mac.com added the comment:

Fixed in r87122.

Thanks you.

--
resolution:  - accepted
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10406] IDLE 2.7 on OS X does not enable Rstrip extension by default

2010-11-20 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

If the release manager agrees, I think the change is okay.

--
nosy: +benjamin.peterson, eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10406] IDLE 2.7 on OS X does not enable Rstrip extension by default

2010-11-13 Thread Ned Deily

New submission from Ned Deily n...@acm.org:

r73001 for Issue5150 added the Rstrip extension to IDLE and modified the 
extensions configuration file, config-extensions.def, to enable it by default.  
For Python 2 OS X installs, however, the config-extensions.def file from 
Lib/idlelib is replaced by a tailored one from Mac/IDLE and the changes for 
Issue5101 are lost.  The attached patch updates the Mac/IDLE version 
appropriately.  Note, for Python 3 installs, this is not a problem as there is 
no longer a separate Mac-only copy of the file.

--
assignee: ronaldoussoren
components: IDLE, Macintosh
messages: 121123
nosy: Bruce.Sherwood, kbk, ned.deily, ronaldoussoren, taleinat
priority: normal
severity: normal
stage: patch review
status: open
title: IDLE 2.7 on OS X does not enable Rstrip extension by default
type: performance
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10406] IDLE 2.7 on OS X does not enable Rstrip extension by default

2010-11-13 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


Added file: http://bugs.python.org/file19593/issue10406-idle27-rstrip-27.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: rstrip()

2010-07-19 Thread News123
Dennis Lee Bieber wrote:
 On Sun, 18 Jul 2010 17:49:11 +0100, MRAB pyt...@mrabarnett.plus.com
 declaimed the following in gmane.comp.python.general:
 
 How about 'strip_str', 'lstrip_str' and 'rstrip_str', or something
 
   Not sure what the first would do... unless one is envisioning
 
   abracadabra.strip_str(abra)...
 
   For the others... trim_suffix, trim_prefix are more explicit in
 meaning -- after all, someone might ask if there is an *strip_unicode
 too! (or _bytes). That still leaves the question of what the desired
 behavior of
 
   Shanana.trim_suffix(na) 
 
 is to produce? Sha or Shana?
 
 


What I'd imagine would be stripping of a suffix or the first match in a
list of suffixes exactly once.

TO me this seems the most common use case, though one is surprised how
functions can be used.


Example:

def strip_suffix(str,*suffixes):
for suffix in suffixes:
if str.endswith(suffix):
return str[-len(suffix):]
return str
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-18 Thread News123
Mark Lawrence wrote:
 On 17/07/2010 23:17, MRAB wrote:
 Chris Rebert wrote:
 On Fri, Jul 16, 2010 at 10:27 AM, MRAB pyt...@mrabarnett.plus.com
 wrote:
 Jason Friedman wrote:

 It's a pity that str.strip() doesn't actually take a set() of length-1
 strings, which would make its behavior more obvious and cut down on
 this perennial question.

 Even better, a set (or tuple) of strings. It's the kind of thing that
 could've been done in Python 3, with Python 2's .strip(string) becoming
 .strip(set(string)), but it didn't occur to me until too late. :-(
 
 Maybe 3.2 which is still in alpha, if not 3.3?
 
 Kindest regards.
 
 Mark Lawrence.
 

It could even be introduced without breaking compatibility.

if being defined as
str.rstrip([iterable])
so you could either call
string.rstrip( [ '-dir' ] )
or  as
string.rstrip( '-dir' )


However I wouldn't be sure, that it really reduces the amount of
questions being asked.

In order to reduce the ambiguities one had to have two distinct functions.
If one wouldn't want to break backwards-compatibility, then the new
names would be  for stripping off prefixes / suffixes and could be
str.strip_prefix(prefixes) / str.rstrip_suffix(suffixes)


I'd love to have this functionality, though I can live with importing my
self written function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-18 Thread Thomas Jollans
On 07/18/2010 01:18 PM, News123 wrote:
 Mark Lawrence wrote:
 On 17/07/2010 23:17, MRAB wrote:
 Chris Rebert wrote:
 On Fri, Jul 16, 2010 at 10:27 AM, MRAB pyt...@mrabarnett.plus.com
 wrote:
 Jason Friedman wrote:

 It's a pity that str.strip() doesn't actually take a set() of length-1
 strings, which would make its behavior more obvious and cut down on
 this perennial question.

 Even better, a set (or tuple) of strings. It's the kind of thing that
 could've been done in Python 3, with Python 2's .strip(string) becoming
 .strip(set(string)), but it didn't occur to me until too late. :-(

 Maybe 3.2 which is still in alpha, if not 3.3?

 Kindest regards.

 Mark Lawrence.

 
 It could even be introduced without breaking compatibility.
 
 if being defined as
 str.rstrip([iterable])
 so you could either call


 string.rstrip( [ '-dir' ] )
 or  as
 string.rstrip( '-dir' )

The former should certainly raise an exception. '-dir' is not a single
character !
Or it should actually strip '-dir', or '-dir-dir', but not 'r--i'... but
that's just silly.

 
 
 However I wouldn't be sure, that it really reduces the amount of
 questions being asked.
 
 In order to reduce the ambiguities one had to have two distinct functions.
 If one wouldn't want to break backwards-compatibility, then the new
 names would be  for stripping off prefixes / suffixes and could be
 str.strip_prefix(prefixes) / str.rstrip_suffix(suffixes)
 
 
 I'd love to have this functionality, though I can live with importing my
 self written function.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-18 Thread News123
Thomas Jollans wrote:

 
 
 string.rstrip( [ '-dir' ] )
 or  as
 string.rstrip( '-dir' )
 
 The former should certainly raise an exception. '-dir' is not a single
 character !
 Or it should actually strip '-dir', or '-dir-dir', but not 'r--i'... but
 that's just silly.
 
It's silly with the example of '-dir' it's much less silly with
a string like ' \t'.

The doc is rather clear about it:
str.rstrip([chars])

It is marked 'chars' and not 'suffix'

The textual description is even clearer:
The chars argument is not a suffix; rather, all combinations of its
values are stripped:


When  I asked in this grpup about a way of how to strip off a prefix I
never even considered strip as a solution having read the doc before.

I also think, that the functionality of strip / rstrip is useful as is.


It would just be great to have functions to strip  prefixes/suffixes.
If these new commands were alphabetically next to the classic  commands,
( e.g. strip_prefix / rstrip_suffix)  then almost everybody looking for
string functions would probably use the function, which is appropriate
for his purpose.

Breaking backwardscompatibility within python 3 might not be the best
choice.

 However I wouldn't be sure, that it really reduces the amount of
 questions being asked.

 In order to reduce the ambiguities one had to have two distinct functions.
 If one wouldn't want to break backwards-compatibility, then the new
 names would be  for stripping off prefixes / suffixes and could be
 str.strip_prefix(prefixes) / str.rstrip_suffix(suffixes)


 I'd love to have this functionality, though I can live with importing my
 self written function.
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-18 Thread MRAB

News123 wrote:

Thomas Jollans wrote:




string.rstrip( [ '-dir' ] )
or  as
string.rstrip( '-dir' )

The former should certainly raise an exception. '-dir' is not a single
character !
Or it should actually strip '-dir', or '-dir-dir', but not 'r--i'... but
that's just silly.


It's silly with the example of '-dir' it's much less silly with
a string like ' \t'.

The doc is rather clear about it:
str.rstrip([chars])

It is marked 'chars' and not 'suffix'

The textual description is even clearer:
The chars argument is not a suffix; rather, all combinations of its
values are stripped:


When  I asked in this grpup about a way of how to strip off a prefix I
never even considered strip as a solution having read the doc before.

I also think, that the functionality of strip / rstrip is useful as is.


It would just be great to have functions to strip  prefixes/suffixes.
If these new commands were alphabetically next to the classic  commands,
( e.g. strip_prefix / rstrip_suffix)  then almost everybody looking for
string functions would probably use the function, which is appropriate
for his purpose.

Breaking backwardscompatibility within python 3 might not be the best
choice.


[snip]
How about 'strip_str', 'lstrip_str' and 'rstrip_str', or something
similar?
--
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-18 Thread News123
MRAB wrote:
 News123 wrote:
 Thomas Jollans wrote:


 string.rstrip( [ '-dir' ] )
 or  as
 string.rstrip( '-dir' )
 The former should certainly raise an exception. '-dir' is not a single
 character !
 Or it should actually strip '-dir', or '-dir-dir', but not 'r--i'... but
 that's just silly.

 It's silly with the example of '-dir' it's much less silly with
 a string like ' \t'.

 The doc is rather clear about it:
 str.rstrip([chars])

 It is marked 'chars' and not 'suffix'

 The textual description is even clearer:
 The chars argument is not a suffix; rather, all combinations of its
 values are stripped:


 When  I asked in this grpup about a way of how to strip off a prefix I
 never even considered strip as a solution having read the doc before.

 I also think, that the functionality of strip / rstrip is useful as is.


 It would just be great to have functions to strip  prefixes/suffixes.
 If these new commands were alphabetically next to the classic  commands,
 ( e.g. strip_prefix / rstrip_suffix)  then almost everybody looking for
 string functions would probably use the function, which is appropriate
 for his purpose.

 Breaking backwardscompatibility within python 3 might not be the best
 choice.

 [snip]
 How about 'strip_str', 'lstrip_str' and 'rstrip_str', or something
 similar?

sounds reasonable to me
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-18 Thread Ethan Furman

MRAB wrote:

[snip]
How about 'strip_str', 'lstrip_str' and 'rstrip_str', or something
similar?


+1 on the names

~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-18 Thread python
And don't forget the oft requested strip_tease().

Malcolm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-17 Thread News123
Jason Friedman wrote:
 $ python
 Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
 [GCC 4.4.1] on linux2
 Type help, copyright, credits or license for more information.
 x.vsd-dir.rstrip(-dir)
 'x.vs'
 
 I expected 'x.vsd' as a return value.

This is kind of similiar to the question, that I posted recently.
nicer way to remove prefix of a string if it exists



if you want to remove '-dir' at the end of the string if it exists and
leave the string as it is if it is not followed by '-dir',

then you could do:

def rmv_suffix(suffix,txt):
if txt.endswith(suffix):
return txt[:-len(suffix)]
return txt

 rmv_suffix('-dir','abcd')
'abcd'
 rmv_suffix('-dir','abcd-dir')
'abcd'
 rmv_suffix('-dir','abcd-dir-and then more')
'abcd-dir-and then more'



the other solution would involve regular expressions:


import re
 re.sub('-dir$','','abcd')
'abcd'
 re.sub('-dir$','','abcd-dir')
'abcd'
 re.sub('-dir$','','abcd-dirand more')
'abcd-dirand more'




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-17 Thread Chris Rebert
On Fri, Jul 16, 2010 at 10:27 AM, MRAB pyt...@mrabarnett.plus.com wrote:
 Jason Friedman wrote:

 $ python
 Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
 [GCC 4.4.1] on linux2
 Type help, copyright, credits or license for more information.

 x.vsd-dir.rstrip(-dir)

 'x.vs'

 I expected 'x.vsd' as a return value.

 .strip, .lstrip and .rstrip treat their argument like a set of
 characters and remove any of those characters from the end(s) of the
 string.

It's a pity that str.strip() doesn't actually take a set() of length-1
strings, which would make its behavior more obvious and cut down on
this perennial question.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-17 Thread MRAB

Chris Rebert wrote:

On Fri, Jul 16, 2010 at 10:27 AM, MRAB pyt...@mrabarnett.plus.com wrote:

Jason Friedman wrote:

$ python
Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type help, copyright, credits or license for more information.

x.vsd-dir.rstrip(-dir)

'x.vs'

I expected 'x.vsd' as a return value.

.strip, .lstrip and .rstrip treat their argument like a set of
characters and remove any of those characters from the end(s) of the
string.


It's a pity that str.strip() doesn't actually take a set() of length-1
strings, which would make its behavior more obvious and cut down on
this perennial question.


Even better, a set (or tuple) of strings. It's the kind of thing that
could've been done in Python 3, with Python 2's .strip(string) becoming
.strip(set(string)), but it didn't occur to me until too late. :-(
--
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-17 Thread Mark Lawrence

On 17/07/2010 23:17, MRAB wrote:

Chris Rebert wrote:

On Fri, Jul 16, 2010 at 10:27 AM, MRAB pyt...@mrabarnett.plus.com
wrote:

Jason Friedman wrote:

$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type help, copyright, credits or license for more information.

x.vsd-dir.rstrip(-dir)

'x.vs'

I expected 'x.vsd' as a return value.

.strip, .lstrip and .rstrip treat their argument like a set of
characters and remove any of those characters from the end(s) of the
string.


It's a pity that str.strip() doesn't actually take a set() of length-1
strings, which would make its behavior more obvious and cut down on
this perennial question.


Even better, a set (or tuple) of strings. It's the kind of thing that
could've been done in Python 3, with Python 2's .strip(string) becoming
.strip(set(string)), but it didn't occur to me until too late. :-(


Maybe 3.2 which is still in alpha, if not 3.3?

Kindest regards.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


rstrip()

2010-07-16 Thread Jason Friedman
$ python
Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type help, copyright, credits or license for more information.
 x.vsd-dir.rstrip(-dir)
'x.vs'

I expected 'x.vsd' as a return value.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-16 Thread Shashwat Anand
On Fri, Jul 16, 2010 at 10:28 PM, Jason Friedman ja...@powerpull.netwrote:

 $ python
 Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
 [GCC 4.4.1] on linux2
 Type help, copyright, credits or license for more information.
  x.vsd-dir.rstrip(-dir)
 'x.vs'

 I expected 'x.vsd' as a return value.


rstrip([chars])
The chars are stripped from right.
Here it's ['-', 'd','i','r'] , hence these 4 characters will be stripped
from right, so you are left with 'x.vs'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-16 Thread Thomas Jollans
On 07/16/2010 06:58 PM, Jason Friedman wrote:
 $ python
 Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
 [GCC 4.4.1] on linux2
 Type help, copyright, credits or license for more information.
 x.vsd-dir.rstrip(-dir)
 'x.vs'
 
 I expected 'x.vsd' as a return value.

 x-vsd-dir.rstrip(-dir)
'x-vs'
 x-vsd-dir.rstrip(123id-r456)
'x-vs'
 x-vsd-dir.rstrip(-di)
'x-vsd-dir'
 fooabc.rstrip(bca)
'foo'


http://docs.python.org/py3k/library/stdtypes.html#str.rstrip ::

 The chars argument is not a suffix; rather, all combinations of its
values are stripped: 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-16 Thread Ken Watford
On Fri, Jul 16, 2010 at 12:58 PM, Jason Friedman ja...@powerpull.net wrote:
 $ python
 Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
 [GCC 4.4.1] on linux2
 Type help, copyright, credits or license for more information.
 x.vsd-dir.rstrip(-dir)
 'x.vs'

 I expected 'x.vsd' as a return value.
 --
 http://mail.python.org/mailman/listinfo/python-list


rstrip strips a given set of characters, not a specific string. '-dir'
contains d, so the trailing d is also stripped.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-16 Thread MRAB

Jason Friedman wrote:

$ python
Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type help, copyright, credits or license for more information.

x.vsd-dir.rstrip(-dir)

'x.vs'

I expected 'x.vsd' as a return value.


.strip, .lstrip and .rstrip treat their argument like a set of
characters and remove any of those characters from the end(s) of the
string.

In your example it's removing any -, d, i or r from the
right-hand end of x.vsd-dir, leaving x.vs, like this:

result = x.vsd-dir
characters = -dir
while result and result[-1] in characters:
result = result[ : -1]
--
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip()

2010-07-16 Thread Novocastrian_Nomad
On Jul 16, 10:58 am, Jason Friedman ja...@powerpull.net wrote:
 $ python
 Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
 [GCC 4.4.1] on linux2
 Type help, copyright, credits or license for more information.
 x.vsd-dir.rstrip(-dir)

 'x.vs'

 I expected 'x.vsd' as a return value.

One way to achieve the desired result:
'x.vsd-dir'.split('-')[0]
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue6346] Rstrip Incorrectly Strips Some Strings

2009-06-26 Thread Matt Kubilus

New submission from Matt Kubilus kubil...@yahoo.com:

Rstrip has unexpected behavior with some strings.  Example:

-

 proxa.py.rstrip(.py)
'proxa'
 proxy.py.rstrip(.py)
'prox'

-

Tested with Python 2.6.1

--
components: Library (Lib)
messages: 89736
nosy: mkubilus
severity: normal
status: open
title: Rstrip Incorrectly Strips Some Strings
type: behavior
versions: Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6346
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6346] Rstrip Incorrectly Strips Some Strings

2009-06-26 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

This is expected. rstrip() strips a set of characters, not a string.

--
nosy: +benjamin.peterson
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6346
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6346] Rstrip Incorrectly Strips Some Strings

2009-06-26 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

And you should probably use
http://docs.python.org/library/os.path.html#os.path.splitext instead of
.rstrip().

--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6346
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5318] strip, rstrip lstrip bug

2009-02-19 Thread alexlc

New submission from alexlc a...@niebla.co.uk:

Examples of bad behaviour:

 'abacde'.lstrip('ab')
'cde'
 'abaaacde'.lstrip('ab')
'cde'
 'aabacde'.lstrip('aab')
'cde'
 'abcede'.rstrip( 'de' )
'abc'
 'abacdeaab'.strip('ab')
'cde'

Probably a few more similar to these will fail as well.

I have tested this with a fairly recent 2.5 (maybe 2.53 maybe 2.54), and
with 2.6.1. I have commented this to a friend and he recalls problems
similar to these with lstrip and rstrip a few years ago, so it might
have been an early 2.4 version or a late 2.3.

Thanks.

--
components: Library (Lib)
messages: 82480
nosy: alexlc
severity: normal
status: open
title: strip, rstrip  lstrip bug
type: behavior
versions: Python 2.5, Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5318
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5318] strip, rstrip lstrip bug

2009-02-19 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

This is not a bug:
str.strip([chars])
 ... The chars argument is not a prefix or suffix; rather, all
combinations of its values are stripped: ...

http://docs.python.org/library/stdtypes.html#str.strip

--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5318
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5318] strip, rstrip lstrip bug

2009-02-19 Thread alexlc

alexlc a...@niebla.co.uk added the comment:

Oh, thanks for letting me know and sorry for the trouble.
I should had read the docs more carefully. I have actually been using for a
long while the strip methods as I had described in the bug report. I was so
completely convinced about this that I didn't even thought about checking
again the docs.
I have to fix my code but I am happy nonetheless as I was kind of 'losing my
faith' in python after finding this.

Regards,
Alejandro

2009/2/19 Ezio Melotti rep...@bugs.python.org


 Ezio Melotti ezio.melo...@gmail.com added the comment:

 This is not a bug:
 str.strip([chars])
  ... The chars argument is not a prefix or suffix; rather, all
 combinations of its values are stripped: ...

 http://docs.python.org/library/stdtypes.html#str.strip

 --
 nosy: +ezio.melotti

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue5318
 ___


Added file: http://bugs.python.org/file13139/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5318
___Oh, thanks for letting me know and sorry for the trouble.brI should had read 
the docs more carefully. I have actually been using for a long while the strip 
methods as I had described in the bug report. I was so completely convinced 
about this that I didn#39;t even thought about checking again the docs.br
I have to fix my code but I am happy nonetheless as I was kind of #39;losing 
my faith#39; in python after finding 
this.brbrRegards,brAlejandrobrbrbrdiv 
class=gmail_quote2009/2/19 Ezio Melotti span dir=ltrlt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/spanbr
blockquote class=gmail_quote style=border-left: 1px solid rgb(204, 204, 
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;br
Ezio Melotti lt;a 
href=mailto:ezio.melo...@gmail.com;ezio.melo...@gmail.com/agt; added the 
comment:br
br
This is not a bug:br
str.strip([chars])br
nbsp;... The chars argument is not a prefix or suffix; rather, allbr
combinations of its values are stripped: ...br
br
a href=http://docs.python.org/library/stdtypes.html#str.strip; 
target=_blankhttp://docs.python.org/library/stdtypes.html#str.strip/abr
br
--br
nosy: +ezio.melottibr
divdiv/divdiv class=Wj3C7cbr
___br
Python tracker lt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;br
lt;a href=http://bugs.python.org/issue5318; 
target=_blankhttp://bugs.python.org/issue5318/agt;br
___br
/div/div/blockquote/divbr
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5318] strip, rstrip lstrip bug

2009-02-19 Thread Daniel Diniz

Daniel Diniz aja...@gmail.com added the comment:

Thanks, Ezio!

--
nosy: +ajaksu2
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5318
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: rstrip error python2.4.3 not in 2.5.1?

2008-02-29 Thread dirkheld


 What is the actual error message [SyntaxError, NameError? etc] that you
 clipped?

Here it is : I tought that I didn't matter because the deliciousapi
worked fine on my mac.

Traceback (most recent call last):
  File delgraph.py, line 62, in ?
url_metadata = d.get_url(site.rstrip())
  File deliciousapi.py, line 269, in get_url
document.bookmarks =
self._extract_bookmarks_from_url_history(data)
  File deliciousapi.py, line 297, in
_extract_bookmarks_from_url_history
timestamp = datetime.datetime.strptime(month_string, '%b lsquo;
%y')
AttributeError: type object 'datetime.datetime' has no attribute
'strptime'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip error python2.4.3 not in 2.5.1?

2008-02-29 Thread Philipp Pagel
dirkheld [EMAIL PROTECTED] wrote:

 Here it is : I tought that I didn't matter because the deliciousapi
 worked fine on my mac.

 Traceback (most recent call last):
   File delgraph.py, line 62, in ?
 url_metadata = d.get_url(site.rstrip())
   File deliciousapi.py, line 269, in get_url
 document.bookmarks =
 self._extract_bookmarks_from_url_history(data)
   File deliciousapi.py, line 297, in
 _extract_bookmarks_from_url_history
 timestamp = datetime.datetime.strptime(month_string, '%b lsquo;
 %y')
 AttributeError: type object 'datetime.datetime' has no attribute
 'strptime'

The answer is right there: datetime.datetime has method strptime in
python 2.5 but which was not available in 2.4. A quick look into the
library reference confirms this:

--
strptime(   date_string, format)
Return a datetime corresponding to date_string, parsed according to 
format.
This is equivalent to datetime(*(time.strptime(date_string, format)[0:6])).
ValueError is raised if the date_string and format can't be parsed by
time.strptime() or if it returns a value which isn't a time tuple.

New in version 2.5. 
--

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl f. Genomorientierte Bioinformatik
Technische Universität München
http://mips.gsf.de/staff/pagel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip error python2.4.3 not in 2.5.1?

2008-02-29 Thread Tim Roberts
dirkheld [EMAIL PROTECTED] wrote:

 What is the actual error message [SyntaxError, NameError? etc] that you
 clipped?

Here it is : I tought that I didn't matter because the deliciousapi
worked fine on my mac.

Traceback (most recent call last):
  File delgraph.py, line 62, in ?
url_metadata = d.get_url(site.rstrip())
  File deliciousapi.py, line 269, in get_url
document.bookmarks = self._extract_bookmarks_from_url_history(data)
  File deliciousapi.py, line 297, in
_extract_bookmarks_from_url_history
timestamp = datetime.datetime.strptime(month_string, '%b lsquo;
%y')
AttributeError: type object 'datetime.datetime' has no attribute
'strptime'

I suppose it is cruel of me, but I find it hilarious that you looked at
this traceback and came to the conclusion that the problem was in rstrip.
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


rstrip error python2.4.3 not in 2.5.1?

2008-02-28 Thread dirkheld
Hi,

I wrote some python code that retrieves urls from a txt file. In this
code I use .rstrip() for removing the '\n' at the end of every url.
While this code works on my mac (leopard) with python 2.5.1, this same
code fails to work on an ubuntu server with python 2.4.3

I was wondering if there is a problem with .rstrip() in that python
version?

error :
Traceback (most recent call last):
  File delgraph.py, line 62, in ?
url_metadata = d.get_url(site.rstrip())
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip error python2.4.3 not in 2.5.1?

2008-02-28 Thread Terry Reedy

dirkheld [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
| Hi,
|
| I wrote some python code that retrieves urls from a txt file. In this
| code I use .rstrip() for removing the '\n' at the end of every url.
| While this code works on my mac (leopard) with python 2.5.1, this same
| code fails to work on an ubuntu server with python 2.4.3
|
| I was wondering if there is a problem with .rstrip() in that python
| version?
|
| error :
| Traceback (most recent call last):
|  File delgraph.py, line 62, in ?
|url_metadata = d.get_url(site.rstrip())
| -- 

What is the actual error message [SyntaxError, NameError? etc] that you 
clipped? 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rstrip error python2.4.3 not in 2.5.1?

2008-02-28 Thread subeen
rstrip() works fine in python 2.4.3. May be the problem lies in
somewhere else.

I tried it in FC6 with Python 2.4.3:
 url = abc.com\n
 url.rstrip()
'abc.com'


regards,
Subeen.
http://love-python.blogspot.com/

On Feb 29, 2:30 am, dirkheld [EMAIL PROTECTED] wrote:
 Hi,

 I wrote some python code that retrieves urls from a txt file. In this
 code I use .rstrip() for removing the '\n' at the end of every url.
 While this code works on my mac (leopard) with python 2.5.1, this same
 code fails to work on an ubuntu server with python 2.4.3

 I was wondering if there is a problem with .rstrip() in that python
 version?

 error :
 Traceback (most recent call last):
   File delgraph.py, line 62, in ?
 url_metadata = d.get_url(site.rstrip())

-- 
http://mail.python.org/mailman/listinfo/python-list


[ python-Bugs-1388489 ] bug in rstrip lstrip

2005-12-22 Thread SourceForge.net
Bugs item #1388489, was opened at 2005-12-23 01:43
Message generated for change (Comment added) made by doerwalter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1388489group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Jason Whitlark (jcdelta)
Assigned to: Nobody/Anonymous (nobody)
Summary: bug in rstrip  lstrip

Initial Comment:
quick detail:
snip
Python 2.4.2 (#1, Dec  9 2005, 22:48:42)
[GCC 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)] on
linux2
Type help, copyright, credits or license for
more information.
 net.tpl.rstrip('.tpl')
'ne'
 foo.tpl.rstrip('.tpl')
'foo'
/snip

I ran the following code to test this:
snip
26 - [EMAIL PROTECTED]: ~/pythonBugTest
0 cat testForRStripBug.py
#! /usr/bin/python

for word in
open('/opt/openoffice/share/dict/ooo/en_US.dic', 'r'):
word = word.split('/')[0]
testWord = (word + '.tpl').rstrip('.tpl')
if word != testWord:
print word, testWord
/snip

And came up with the attached file of incorrect
matches.  Out of 62075 words in the en_US.dic, 6864 do
not match.  Here is the frequency count of the last
letter of the origional word, the only pattern I could
discern so far:
snip
0 ./freqCount.py  run1
{'p': 566, 'l': 2437, 't': 3861}
/snip

No other letters seem to be clipped.  Why this should
be so, I have no idea.  I would guess that the error
was in function do_xstrip in
python/trunk/Objects/stringobject.c, but C is not my
strong suit.  I will be looking at it further when I
have time, but if anyone knows how to fix this, please
help.

--

Comment By: Walter Dörwald (doerwalter)
Date: 2005-12-23 02:23

Message:
Logged In: YES 
user_id=89016

This is not a bug. The documentation
(http://docs.python.org/lib/string-methods.html) says that:
The chars argument is a string specifying the set of
characters to be removed. i.e. net.tpl.rstrip(.tpl)
strips every ., t, p and l character from the right
end of the string, *not* every occurence of the character
sequence .tpl. This seems to be a frequent
misunderstanding, so if you can suggest improvements to the
docstring or the documentation, please do so. 

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1388489group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1104923 ] Bug in String rstrip method

2005-01-18 Thread SourceForge.net
Bugs item #1104923, was opened at 2005-01-18 19:58
Message generated for change (Comment added) made by dsm001
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1104923group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Rick Coupland (rcouplan)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug in String rstrip method

Initial Comment:
There appears to be a data sensitive bug in the string rstrip 
method as demonstrated by the following code: 
 
 ecigrcal.fle.rstrip(.fle) 
'ecigrca' 
 
As you can see, it is striping an extra character. 

--

Comment By: DSM (dsm001)
Date: 2005-01-18 20:51

Message:
Logged In: YES 
user_id=1175690

I don't think this is a bug.  The documentation for the
rstrip method reads:

rstrip(...)
S.rstrip([chars]) - string or unicode

Return a copy of the string S with trailing whitespace
removed.
If chars is given and not None, remove characters in
chars instead.

When you pass the method .rle, you're telling it to treat
the four characters ., r, l, and e as trailing
whitespace and remove them from the right side of the
string.  That's why it removes the extra l.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1104923group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com