ˇ@

Home 

python Programming Glossary: tuples

Remove items from a list while iterating in Python

http://stackoverflow.com/questions/1207406/remove-items-from-a-list-while-iterating-in-python

while iterating in Python I'm iterating over a list of tuples in Python and am attempting to remove them if they meet certain..

A Transpose/Unzip Function in Python (inverse of zip)

http://stackoverflow.com/questions/19339/a-transpose-unzip-function-in-python-inverse-of-zip

Function in Python inverse of zip I have a list of 2 item tuples and I'd like to convert them to 2 lists where the first contains..

How does zip(*[iter(s)]*n) work in Python?

http://stackoverflow.com/questions/2233204/how-does-zipitersn-work-in-python

you pass to zip three identical iterators and zip makes 3 tuples of the integers ”in order ”from each of the three iterators 1..

The Python yield keyword explained

http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained

expects iterables so it will work with strings lists tuples and generators This is called duck typing and is one of the..

What are “named tuples” in Python?

http://stackoverflow.com/questions/2970608/what-are-named-tuples-in-python

are &ldquo named tuples&rdquo in Python Reading the changes in Python 3.1 I found something..... tuple is now a named tuple I never heard about named tuples before and I thought elements could either be indexed by numbers.. elements could either be indexed by numbers like in tuples and lists or by keys like in dicts . I never expected they could..

How to improve performance of this code?

http://stackoverflow.com/questions/4295799/how-to-improve-performance-of-this-code

items so you will have to change your configurations into tuples instead of lists. If the order of closedlist is crucial to the..

What is the most “pythonic” way to iterate over a list in chunks?

http://stackoverflow.com/questions/434287/what-is-the-most-pythonic-way-to-iterate-over-a-list-in-chunks

input or I'd have it passed in as a list of four element tuples. Currently I'm iterating over it this way for i in xrange 0..

Python: Sort a dictionary by value

http://stackoverflow.com/questions/613183/python-sort-a-dictionary-by-value

there a simpler solution. python list dictionary sorting tuples share improve this question It is not possible to sort a.. are inherently orderless but other types such as lists and tuples are not. So you need a sorted representation which will be a.. representation which will be a list ”probably a list of tuples. For instance import operator x 1 2 3 4 4 3 2 1 0 0 sorted_x..

What's the difference between list and tuples in Python?

http://stackoverflow.com/questions/626759/whats-the-difference-between-list-and-tuples-in-python

the difference between list and tuples in Python What's the difference What are the advantages disadvantages.. the difference What are the advantages disadvantages of tuples lists python list tuples share improve this question Apart.. the advantages disadvantages of tuples lists python list tuples share improve this question Apart from tuples being immutable..

What is the best way to implement nested dictionaries in Python?

http://stackoverflow.com/questions/635483/what-is-the-best-way-to-implement-nested-dictionaries-in-python

if I want to go over all the values. I could also use tuples as keys like such 'new jersey' 'mercer county' 'plumbers' 3..

How many bytes per element are there in a Python list (tuple)?

http://stackoverflow.com/questions/135664/how-many-bytes-per-element-are-there-in-a-python-list-tuple

module or if you need to do vectorized math use NumPy. PS Tuples unlike lists are not designed to have elements progressively..

How to specify 2 keys in python sorted(list)?

http://stackoverflow.com/questions/16515737/how-to-specify-2-keys-in-python-sortedlist

item is len str and the second one is the string itself. Tuples are then compared lexicographically. That is first the lengths..

Keeping large dictionary in Python affects application performance

http://stackoverflow.com/questions/19391648/keeping-large-dictionary-in-python-affects-application-performance

immutable objects hence the advice to move towards those. Tuples and dicts weren't special cased at all until very late 2008.. import gc gc.is_tracked 4 False gc.is_tracked 2323 False Tuples are initially tracked t1 1 t2 1. gc.is_tracked t1 gc.is_tracked..

Python: what is the difference between (1,2,3) and [1,2,3], and when should I use each?

http://stackoverflow.com/questions/1983/python-what-is-the-difference-between-1-2-3-and-1-2-3-and-when-should-i-us

are generally used in fundamentally different ways. Tuples can be thought of as being similar to Pascal records or C structs..

Why do we need tuples in Python (or any immutable data type)?

http://stackoverflow.com/questions/2174124/why-do-we-need-tuples-in-python-or-any-immutable-data-type

on Python.org I don't see why the language needs tuples. Tuples have no methods compared to a list or set and if I must convert..

Python memory usage? loading large dictionaries in memory

http://stackoverflow.com/questions/2211965/python-memory-usage-loading-large-dictionaries-in-memory

42 31 Note that sys.getsizeof str_object 24 len str_object Tuples were mentioned by one answerer. Note carefully the following..

Best way to define multidimensional dictionaries in python? [duplicate]

http://stackoverflow.com/questions/2388302/best-way-to-define-multidimensional-dictionaries-in-python

1 python data structures share improve this question Tuples are hashable. Probably I'm missing the point but why don't you..

Converting a List of Tuples into a Dict in Python

http://stackoverflow.com/questions/261655/converting-a-list-of-tuples-into-a-dict-in-python

a List of Tuples into a Dict in Python I have a list of tuples like this 'a'..

What are differences between List, Dictionary and Tuple in Python? [duplicate]

http://stackoverflow.com/questions/3649841/what-are-differences-between-list-dictionary-and-tuple-in-python

between a list and a tuple. To quote Nikow's answer Tuples have structure lists have order. A dictionary is a key value..

Why does adding a trailing comma after a string make it a tuple?

http://stackoverflow.com/questions/3750632/why-does-adding-a-trailing-comma-after-a-string-make-it-a-tuple

How can I merge (union) two Python dictionaries in a single expression?

http://stackoverflow.com/questions/38987/how-can-i-merge-union-two-python-dictionaries-in-a-single-expression

How to implement a good __hash__ function in python

http://stackoverflow.com/questions/4005318/how-to-implement-a-good-hash-function-in-python

same hash and with xor these will cancel eachother out. Tuples use a more complex calculation to mix hashes see tuplehash in..

python tuple comparison

http://stackoverflow.com/questions/5292303/python-tuple-comparison

be of the same type and have the same length. Also this Tuples and lists are compared lexicographically using comparison of..

Is it pythonic for a function to return multiple values?

http://stackoverflow.com/questions/61605/is-it-pythonic-for-a-function-to-return-multiple-values

this question Absolutely for the example you provided . Tuples are first class citizens in Python There is a builtin function.. most of the time. Citation from Python Library Reference Tuples are constructed by the comma operator not within square brackets..

What's the difference between list and tuples in Python?

http://stackoverflow.com/questions/626759/whats-the-difference-between-list-and-tuples-in-python

also a semantic distinction that should guide their usage. Tuples are heterogeneous data structures i.e. their entries have different.. different meanings while lists are homogeneous sequences. Tuples have structure lists have order. Using this distinction makes.. are some interesting articles on this issue e.g. Python Tuples are Not Just Constant Lists or Understanding tuples vs. lists..

Compare two different files line by line and write the difference in third file - Python

http://stackoverflow.com/questions/7757626/compare-two-different-files-line-by-line-and-write-the-difference-in-third-file

in f # 2 gives us the first two elements of the list. # Tuples unlike lists cannot be changed which is a requirement for anything..