About 39,600,000 results
Open links in new tab
  1. What's the difference between lists and tuples? - Stack Overflow

    Mar 9, 2009 · What are the differences between lists and tuples, and what are their respective advantages and disadvantages?

  2. python - What is a tuple useful for? - Stack Overflow

    Sep 9, 2014 · A tuple is a good way to pack multiple values into that cookie without having to define a separate class to contain them. I try to be judicious about this particular use, though.

  3. How to create tuple with a loop in python - Stack Overflow

    Feb 17, 2018 · 3 A tuple is an immutable list. This means that, once you create a tuple, it cannot be modified. Read more about tuples and other sequential data types here.

  4. 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 …

  5. python - Convert numpy array to tuple - Stack Overflow

    Apr 5, 2012 · Note: This is asking for the reverse of the usual tuple-to-array conversion. I have to pass an argument to a (wrapped c++) function as a nested tuple. For example, the following …

  6. types - What are "named tuples" in Python? - Stack Overflow

    Jun 4, 2010 · Named tuples are basically easy-to-create, lightweight object types. Named tuple instances can be referenced using object-like variable dereferencing or the standard tuple …

  7. python - Add variables to tuple - Stack Overflow

    The only difference is BUILD_TUPLE_UNPACK vs BINARY_ADD. The exact performance depends on the Python interpreter implementation, but it's natural to implement …

  8. pop/remove items out of a python tuple - Stack Overflow

    However, assuming the OP requires a tuple for output, the difference comes in the conversion back. For proof: take tuple () off the generator and they'll both return instantly, but tuple () the …

  9. Convert list to tuple in Python - Stack Overflow

    Have you assigned the name 'tuple' as a variable name? it should work fine. L is a list and we want to convert it to a tuple. L = [1, 2, 3] tuple (L) By invoking tuple, you convert the list (L) into …

  10. How does tuple comparison work in Python? - Stack Overflow

    Tuples are compared position by position: the first item of the first tuple is compared to the first item of the second tuple; if they are not equal (i.e. the first is greater or smaller than the …

  11. c# - Tuple.Create () vs new Tuple - Stack Overflow

    Dec 13, 2014 · new Tuple<int,int>(1,2); Tuple.Create(1,2); Is there any difference between these two methods of Tuple creation? From my reading it seems to be more a convenient shorthand …

  12. Better naming in Tuple classes than "Item1", "Item2"

    Oct 13, 2011 · The example in the question is using the System.Tuple class to create a Tuple object which is different than using the parenthesis syntax to create a tuple. Your answer …

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

    Feb 1, 2010 · I've read several python tutorials (Dive Into Python, for one), and the language reference on Python.org - I don't see why the language needs tuples. Tuples have no methods …

  14. What are differences between List, Dictionary and Tuple in Python ...

    Sep 6, 2010 · A tuple is similar to a list except it is immutable. There is also a semantic difference between a list and a tuple. To quote Nikow's answer: Tuples have structure, lists have order. A …

  15. c# - What and When to use Tuple? - Stack Overflow

    Nov 30, 2012 · May someone please explain what a Tuple is and how to use it in a Real World Scenario. I would like to find out how this can enrich my coding experience?

  16. python - tuples as function arguments - Stack Overflow

    Jun 7, 2019 · f((2, 3)) # TypeError: f() missing 1 required positional argument: 'b' how does python treat tuples differently when they are function arguments? here the parentheses are necessary …

  17. python - Getting one value from a tuple - Stack Overflow

    The main difference between tuples and lists is that tuples are immutable - you can't set the elements of a tuple to different values, or add or remove elements like you can from a list.

  18. Are tuples more efficient than lists in Python? - Stack Overflow

    Summary Tuples tend to perform better than lists in almost every category: Tuples can be constant folded. Tuples can be reused instead of copied. Tuples are compact and don't over …

  19. IndexError: tuple index out of range ----- Python - Stack Overflow

    Nov 30, 2013 · tuple are index based (and also immutable) in Python. Here in this case x = rows[1][1] + " " + rows[1][2] have only two index 0, 1 available but you are trying to access the …

  20. AttributeError: 'tuple' object has no attribute - Stack Overflow

    Jun 25, 2013 · This is what is called a tuple, obj is associated with 4 values, the values of s1,s2,s3,s4. So, use index as you use in a list to get the value you want, in order.