I am trying to create a list of empty lists: [[], [], [], ...] (10
items total).

What is the most Pythonic way to do this?

If I use a list comprehension (as in myList = [[] for item in xrange
(0, 10)]), Netbeans warns me that 'item' is never used.

Not using Netbeans, I can't verify that the below will stop the warning. However the variable name "_" is used conventionally to mean "this doesn't matter". Additionally, the starting point for xrange defaults to 0, so you can omit it. That would translate to

 my_list = [[] for _ in xrange(10)]

-tkc


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to