Re: lists and for loops

2011-08-18 Thread Mark Niemczyk
Or, using list comprehension. >>> numbers = [1, 2, 3, 4, 5] >>> numbers = [n + 5 for n in numbers] >>> numbers [6, 7, 8, 9, 10] -- http://mail.python.org/mailman/listinfo/python-list

Re: How best to convert a string "list" to a python list

2011-05-13 Thread Mark Niemczyk
;, 'blue', 'green', 'yellow'] >>> Here is the link to a discussion of the build-in str methods (3.2), but this documentation exists for prior versions of Python as well. http://docs.python.org/py3k/library/stdtypes.html#str.split Good luck, Mark Niemczyk -- http://mail.python.org/mailman/listinfo/python-list

Re: De-tupleizing a list

2011-04-26 Thread Mark Niemczyk
Some interesting performance comparisons, under Python 3.2. Times are relative, and are for an initial list of tuples with 500,000 items. (1)ans = [] #relative time: 298 for item in lst: ans += list(item

Re: dictionary size changed during iteration

2011-04-22 Thread Mark Niemczyk
As of Python 3.x (which I suspect you are running): "The objects returned by dict.keys(), dict.values() and dict.items() are view objects. They provide a dynamic view on the dictionary’s entries, which means that when the dictionary changes, the view reflects these changes.", and "Iterating vi