Tuples

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Jan 31 22:39:15 EST 2000


Gerrit Holl wrote:
> 
> With tuples, some things aren't really Pythonic. In some cases, even
> the Perl-like TMTOWTDI thing is true!
> a[1,2] = 'f'
> is equivalent to:
> a=[(1,2)] = 'f'

Yes -- for exactly the same reason that

    a = 42

is equivalent to

   a = (42)


> And:
> "aaa %s bbb" % 'foo'
> is equivalent to:
> "aaa %s bbb" % ('foo',)

Here, Guido evidently considered that the one-argument
case was sufficiently common, and the general way of
writing it sufficiently ugly, that a special case was
justified. I'm inclined to agree with him -- in this
case, it does improve readability.

-- 
Greg Ewing, Computer Science Dept,
+--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-list mailing list