Closed Thread
Results 1 to 5 of 5

Thread: Why Tuples not Lists?

  1. #1
    Join Date
    Aug 2009
    Location
    ~/
    Posts
    918
    Rep Power
    19

    Question Why Tuples not Lists?

    Lists make perfect sense to me as I'm familiar with arrays,
    but tuples are a different story. They seem to be some kind
    of "constant" array which can't be modified once created
    (can't replace, delete or append new elements).

    Why would you use such an inflexible data structure,
    when a flexible list is available??

    Disclaimer:
    I'm just a Python newbie

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Why Tuples not Lists?

    Returning multiple values from a function?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Join Date
    Aug 2009
    Location
    ~/
    Posts
    918
    Rep Power
    19

    Re: Why Tuples not Lists?

    Thanks for the reply!!

    I certainly understand inserting multiple values
    (which might be returned from a function),
    into a tuple, but once the tuple is created
    it can't be modified.
    Those same values can be inserted into a list with
    the flexibility of deleting or appending values.

    I'm new to Python, so I'm probably posting before
    I have a full understanding of what the tuple and list
    are much less how to use them.

    Both the tuple and list do look interesting as you can
    store different "data types" in them which you can't
    do with arrays.

    Python does seem to be worth learning.

  5. #4
    Join Date
    Jul 2009
    Location
    Santa Clarita, CA
    Posts
    2,111
    Blog Entries
    47
    Rep Power
    31

    Re: Why Tuples not Lists?

    I think this explains it best, and why you'd want to use a tuple instead of a list.
    Wow I changed my sig!

  6. #5
    Join Date
    Aug 2009
    Location
    ~/
    Posts
    918
    Rep Power
    19

    Re: Why Tuples not Lists?

    Thanks,
    Excellent link, it's good to know
    others are asking the same question.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Beginner C# Tuples
    By chili5 in forum CSharp Tutorials
    Replies: 0
    Last Post: 08-23-2011, 04:38 AM
  2. learning python part 3 (lists, dictionaries and tuples)
    By saeras in forum Python Tutorials
    Replies: 1
    Last Post: 03-04-2011, 07:19 AM
  3. Lists of Tuples in Haskell
    By markyp in forum General Programming
    Replies: 2
    Last Post: 05-18-2010, 12:43 AM
  4. haskell: lists of tuples to list
    By kunti in forum General Programming
    Replies: 1
    Last Post: 10-31-2008, 06:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts