Oct-10-2016, 07:09 AM
(Oct-09-2016, 08:25 AM)snippsat Wrote:(Oct-09-2016, 01:10 AM)ATXpython Wrote: Is it possible to do the above in one list comprehension?No to much in one list comprehension make it long and harder to read.
Seems kind of wasteful to create a list based on another list, if all I'm trying to do is remove certain characters from it.
So it's not ideal at all.
I think it's okay as you have it now.
There are some different way like translate as mention and i can show one with regex.
>>> import re >>> lst = ['hello?', 'wo+rld@', 'toge?the]'] >>> [re.sub(r'[?@\]+.,]', '', item) for item in lst] ['hello', 'world', 'together']Quote:While, I know PEP-8 isn't law, is there any downside to having a line so long in Python?It's to long when you get over 100 if you ask me,around 90'ish is okay.
it depends on typical terminal size. even with big screen terminal programs usually default to to 80 for the width. many do not "fix" wrapping issues so limiting at 79 on these is better. people often leave term programs at the defaults.
i have changed mine to nearly full screen (166 wide, 46 lines, 14 pt font, on 1920x1080). but this also limits me from doing 2 term windows side by side. if i shink 2 term windows they end up nearly at 80 wide. so, despite some of my code being very wide (i have some that exceeds 1000's) i suggest making code fit in 79 .... not even 90-ish ... just 79.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.