[issue43900] string comprehension

2021-04-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Please take this to the python-ideas mailing list:  
https://mail.python.org/mailman3/lists/python-ideas.python.org/

If the idea gains traction, it would likely require a PEP and then this issue 
can be reopened.

--
nosy: +rhettinger
resolution:  -> later
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



[issue43900] string comprehension

2021-04-20 Thread Zachary Ware


Zachary Ware  added the comment:

filtered_s = ''.join(c for c in s if c in string.ascii_lowercase)

--
nosy: +zach.ware

___
Python tracker 

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



[issue43900] string comprehension

2021-04-20 Thread David Alvarez Lombardi


New submission from David Alvarez Lombardi :

As of now the best way to filter a str is to convert to list, filter, then join 
back to a str. I think a a string comprehension would be very useful for this.


So to get only ascii_lower case chars given this string,

s = "a1b2c3d4"


I could do this

filtered_s = c"ch for ch in s if ch in string.ascii_lowercase"


instead of this.

s_list = []
for i in range(len(s)):
if s[i] in string.ascii_lowercase:
s_list.append(s[i])

filtered_s = "".join(s_list)


--
messages: 391480
nosy: alvarezdqal
priority: normal
severity: normal
status: open
title: string comprehension
type: enhancement
versions: Python 3.10

___
Python tracker 

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