About 292,000 results
Open links in new tab
  1. python - List vs tuple, when to use each? - Stack Overflow

    Using a tuple instead of a list is like having an implied assert statement that this data is constant, and that special thought (and a specific function) is required to override that. Some tuples can be used as …

  2. python - What's the difference between lists and tuples ... - Stack ...

    Mar 9, 2009 · In a list the values all have the same type and the length is not fixed. So the difference is very obvious. Finally there is the namedtuple in Python, which makes sense because a tuple is …

  3. Convert list to tuple in Python - Stack Overflow

    I'm trying to convert a list to a tuple. Most solutions on Google offer the following code:

  4. python - How to sort a list/tuple of lists/tuples by the element at a ...

    Below example, we are sorting a list of tuple that holds the info abt time of certain event and actor name. We are sorting this list by time of event occurrence - which is the 0th element of a tuple. Note - …

  5. python - Convert tuple to list and back - Stack Overflow

    Apr 30, 2013 · NumPy is the fundamental package for scientific computing with Python. NumPy's main object is the homogeneous multidimensional array. It is a table of elements (usually numbers), all of …

  6. How to check if an object is a list or tuple (but not string)?

    This is what I normally do in order to ascertain that the input is a list / tuple - but not a str. Because many times I stumbled upon bugs where a function passes a str object by mistake, and the target function …

  7. Type hinting tuples in Python - Stack Overflow

    Nov 28, 2017 · Like a list of middle names for instance. People may have no middle names, or one, or two or even more middle names. The number of names of any one person will never change, hence …

  8. python - Iterate a list of tuples - Stack Overflow

    I'm looking for a clean way to iterate over a list of tuples where each is a pair like so [(a, b), (c,d) ...]. On top of that I would like to alter the tuples in the list.

  9. python - Using List/Tuple/etc. from typing vs directly referring type ...

    Sep 12, 2016 · What's the difference of using List, Tuple, etc. from typing module: from typing import Tuple def f (points: Tuple): return map (do_stuff, points) As opposed to referring to Python's types dire...

  10. python - Append a tuple to a list - what's the difference between two ...

    Jul 2, 2015 · The tuple function takes only one argument which has to be an iterable tuple([iterable]) Return a tuple whose items are the same and in the same order as iterable‘s items. Try making 3,4 …