Monday, June 12, 2006

Immutability of Tuples and Lists in Python

Python also ships with Cygwin.

Here's a piece using my Cygwin distribution.

This piece demonstrates the immutability of Python lists vs. Python tuples.

Remember that the concept behind "lists" and "tuples" in Python are different from similar mathematical concepts. In mathematics, we often use tuples to refer to various types of orderings. For example, it may be common to say "a measure is a tuple of..."

$ python
Python 2.4.1 (#1, May 27 2005, 18:02:40)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> mytuple = 1,3,2,0
>>> mylist = [1,3,2,0]
>>> mytuple[0]
1
>>> mytyple[0] = 0
Traceback (most recent call last):
File "", line 1, in ?
NameError: name 'mytyple' is not defined
>>> mylist[0]
1
>>> mylist[0]=0
>>> mylist
[0, 3, 2, 0]
>>>

1 comment:

Myself said...

I don't know about iMac, but your system should support persian language or at least arabic, in case you don't want to use especial editor.

This is the editor which I use:
http://www.dodoost.com/aryanevis/
and I use on-screen keyboard. With this editor you will be alright even if your system won't support pesian. It has already persan keyboard to use also.

Any more question?

Good luck