[Tutor] 2 problems in a small script
Dick Moores
rdm at rcblue.com
Sun Oct 14 20:23:55 CEST 2007
**Blush**
These lines were in my last post in this thread:
"Done. I had no idea set could be used that way! With a couple of
modifications, I used your ideas in both <buggy_For_Web5b.py> and
<getCrew_ForWeb2.py> (see the thread I started,
<http://www.nabble.com/An-idea-for-a-script-tf4603558.html#a13149808>)."
They should have read:
"Done. I had no idea set could be used that way! With a couple of
modifications, I used your ideas in both
<http://www.rcblue.com/Python/buggy_For_Web5b.py> and
<http://www.rcblue.com/Python/getCrew_ForWeb2.py> (see the thread I
started,
<http://www.nabble.com/An-idea-for-a-script-tf4603558.html#a13149808>)."
But also, though I'm very glad Ian showed me how to use sets in that
magic way, I had forgotten that a list comprehension can be much more
succinct:
lstB = [ word for word in lstA if all(char in astr for char in word)
] in "buggy" (line 11)
lstD = [ word for word in lstC if all(char in astr for char in word)
] in "getCrew" (line 26)
(Thanks to Kent, I believe.)
These further revisions can be seen at
<http://www.rcblue.com/Python/buggy_For_Web5c.py> and
<http://www.rcblue.com/Python/getCrew_ForWeb3.py>.
Dick
More information about the Tutor
mailing list