Re: Can tuples be replaced with lists all the time?

2014-03-02 Thread Ashish Panchal
No, not always. You can use yuples as dictionary key as keys are immutable and you can't use it as list. -- https://mail.python.org/mailman/listinfo/python-list

Re: Can tuples be replaced with lists all the time?

2014-03-01 Thread Grant Edwards
On 2014-02-23, Sam lightai...@gmail.com wrote: My understanding of Python tuples is that they are like immutable lists. If this is the cause, why can't we replace tuples with lists all the time (just don't reassign the lists)? Correct me if I am wrong. In addition to the things related to

Re: Can tuples be replaced with lists all the time?

2014-03-01 Thread Roy Smith
In article 64af70e3-6876-4fbf-8386-330d2f487...@googlegroups.com, Sam lightai...@gmail.com wrote: My understanding of Python tuples is that they are like immutable lists. If this is the cause, why can't we replace tuples with lists all the time (just don't reassign the lists)? Correct me if

Re: Can tuples be replaced with lists all the time?

2014-03-01 Thread Roy Smith
In article led9s7$req$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: In constrast, tuples are often used as fixed-length heterogenous containers (more like a struct in C except the fields are named 0, 1, 2, 3, etc.). In a particular context, the Nth element of a tuple

Re: Can tuples be replaced with lists all the time?

2014-03-01 Thread Mark Lawrence
On 23/02/2014 17:48, Roy Smith wrote: In article led9s7$req$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: In constrast, tuples are often used as fixed-length heterogenous containers (more like a struct in C except the fields are named 0, 1, 2, 3, etc.). In a

Re: Can tuples be replaced with lists all the time?

2014-03-01 Thread Terry Reedy
On 3/1/2014 4:20 PM, Mark Lawrence wrote: On 23/02/2014 17:48, Roy Smith wrote: It also appears that tuples are more memory efficient. I just ran some quick tests on my OSX box. Creating a list of 10 million [1, 2, 3, 4, 5] lists gave me a 1445 MB process. The name number of (1, 2, 3, 4,

Re: Can tuples be replaced with lists all the time?

2014-02-23 Thread 88888 Dihedral
On Sunday, February 23, 2014 12:06:13 PM UTC+8, Sam wrote: My understanding of Python tuples is that they are like immutable lists. If this is the cause, why can't we replace tuples with lists all the time (just don't reassign the lists)? Correct me if I am wrong. == OK, lets be serious

Can tuples be replaced with lists all the time?

2014-02-22 Thread Sam
My understanding of Python tuples is that they are like immutable lists. If this is the cause, why can't we replace tuples with lists all the time (just don't reassign the lists)? Correct me if I am wrong. -- https://mail.python.org/mailman/listinfo/python-list

Re: Can tuples be replaced with lists all the time?

2014-02-22 Thread Paul Rubin
Sam lightai...@gmail.com writes: My understanding of Python tuples is that they are like immutable lists. If this is the cause, why can't we replace tuples with lists all the time (just don't reassign the lists)? You can do that a lot of the time but not always. For example, you can use a

Re: Can tuples be replaced with lists all the time?

2014-02-22 Thread Chris Angelico
On Sun, Feb 23, 2014 at 3:06 PM, Sam lightai...@gmail.com wrote: My understanding of Python tuples is that they are like immutable lists. If this is the cause, why can't we replace tuples with lists all the time (just don't reassign the lists)? Correct me if I am wrong. One reason is

Re: Can tuples be replaced with lists all the time?

2014-02-22 Thread Ben Finney
Sam lightai...@gmail.com writes: My understanding of Python tuples is that they are like immutable lists. That's a common expression, but I think it's not a helpful way to think of them. Rather, the different sequence types have different semantic purposes: * For representing a sequence