Misuse of list comprehensions?

L

Lie

No, it doesn't. It uses append because it refers to itself in the
if-expression. So the append(c) is needed - and thus the assignment
possible but essentially useless.

Diez

Yes it does, it build a list of 'None's.

And if list.append is concerned, the example given has no use, since:
x = [c for c in cs]
is essentially the same as
x = []
[x.append(c) for c in cs]

If, you're talking about other function calls, it might be an abuse or
not depending on personal preference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,048
Members
48,769
Latest member
Clifft

Latest Threads

Top