what is the difference between the two kinds of brackets?

James Stroud jstroud at mbi.ucla.edu
Sat Oct 20 06:41:02 EDT 2007


narutocanada at gmail.com wrote:
> hi
> 
> what is the difference between the two kinds of brackets?
> I tried a few examples but I can't make out any real difference:
> Are these two kinds of brackets mean the same thing in the "list"
> context? Thanks.


The square ones designate lists:

     http://docs.python.org/tut/node7.html

The rounded ones designate tuples:

     http://docs.python.org/tut/node7.html#SECTION007300000000000000000

The short of it is that lists can change and tuples can not.

<commentary>The long of it is that there are deep computer-science 
issues that distinguish the two and the differences become more 
important the more you know (presumably). However, I have been 
programming this language for 5 years, and I still can't figure out the 
necessity for having both. I have heard all of the arguments, however 
but none are terribly pursuasive.</commentary>

Practically speaking, however, if you don't know which one to use, then 
use the square kind.

James


-- 
James Stroud
UCLA-DOE Institute of Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com



More information about the Python-list mailing list