Tricky Areas in Python
Alex Martelli
aleaxit at yahoo.com
Mon Oct 24 22:38:12 EDT 2005
beza1e1 <andreas.zwinkau at googlemail.com> wrote:
> let me try.
>
> 1) ''.join(lots_of_pieces)
Yep.
> 2) This doesn't even work, if something is removed, the list is too
> short. So:
> [x for x in somelist if not isbad(x)]
> well, list comprehension is Python 2.4 and 2.3 is the standard in many
> OSes, so it is possibly not the most portable solution
No, LC goes back a long way -- I think it was in 2.0 already, 2.1 for
sure. If you have to support (say) Python 1.5.2, the simplest (not
fastest) solution is to loop on a COPY of the list, rather than the very
list you're also modifying.
> I had to look up the syntax, because i never use it in my code, yet.
>
> 3+4) I never used property - had to look it up. So i learned something
> :)
Good!-)
Alex
More information about the Python-list
mailing list