Re: lists v. tuples

2008-03-21 Thread castironpi
On Mar 19, 4:56 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I am puzzled by the failure on 'a in a' for a=[a].  >>> a== [a] also > > fails.  Can we assume/surmise/deduce/infer it's intentional? > > It may be less confusing if instead of an assignment following by a te

Re: lists v. tuples

2008-03-19 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > I am puzzled by the failure on 'a in a' for a=[a]. >>> a== [a] also > fails. Can we assume/surmise/deduce/infer it's intentional? > It may be less confusing if instead of an assignment following by a test you just consider doing the test at the same time as the assig

Re: lists v. tuples

2008-03-18 Thread castironpi
> >> >>> b in b > >> False > > > That's actually interesting. > > Just for the avoidance of doubt, I didn't write the 'b in b' line: > castironpi is replying to himself without attribution. > > P.S. I still don't see the relevance of any of castironpi's followup to my > post, but since none it made

Re: lists v. tuples

2008-03-18 Thread George Sakkis
On Mar 18, 5:34 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > >> > > On Mar 17, 1:31 pm, Duncan Booth <[EMAIL PROTECTED]> > >> > > wrote: > > >> > >> A common explanation for this is that lists are for homogenous > >> > >> collections, tuples are for when you have heterog

Re: lists v. tuples

2008-03-18 Thread Duncan Booth
[EMAIL PROTECTED] wrote: >> > > On Mar 17, 1:31 pm, Duncan Booth <[EMAIL PROTECTED]> >> > > wrote: >> >> > >> A common explanation for this is that lists are for homogenous >> > >> collections, tuples are for when you have heterogenous >> > >> collections i.e. related but different things. >> >>

Re: lists v. tuples

2008-03-18 Thread castironpi
> > > On Mar 17, 1:31 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > > > >> A common explanation for this is that lists are for homogenous > > >> collections, tuples are for when you have heterogenous collections i.e. > > >> related but different things. > > > > I interpret this as meaning that in a

Re: lists v. tuples

2008-03-17 Thread castironpi
On Mar 17, 11:03 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > Ninereeds <[EMAIL PROTECTED]> wrote: > > On Mar 17, 1:31 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > > >> A common explanation for this is that lists are for homogenous > >> collections, tuples are for when you have heterogenous colle

Re: lists v. tuples

2008-03-17 Thread Duncan Booth
Ninereeds <[EMAIL PROTECTED]> wrote: > On Mar 17, 1:31 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > >> A common explanation for this is that lists are for homogenous >> collections, tuples are for when you have heterogenous collections i.e. >> related but different things. > > I interpret this

Re: lists v. tuples

2008-03-17 Thread Ninereeds
On Mar 17, 1:31 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > A common explanation for this is that lists are for homogenous > collections, tuples are for when you have heterogenous collections i.e. > related but different things. I interpret this as meaning that in a data table, I should have a

Re: lists v. tuples

2008-03-17 Thread Robert Bossy
[EMAIL PROTECTED] wrote: > On Mar 17, 6:49 am, [EMAIL PROTECTED] wrote: > >> What are the considerations in choosing between: >> >>return [a, b, c] >> >> and >> >> return (a, b, c) # or return a, b, c >> >> Why is the immutable form the default? >> > > Using a house definition from

Re: lists v. tuples

2008-03-17 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > What are the considerations in choosing between: > >return [a, b, c] > > and > > return (a, b, c) # or return a, b, c > A common explanation for this is that lists are for homogenous collections, tuples are for when you have heterogenous collections i.e. re

Re: lists v. tuples

2008-03-17 Thread Steven D'Aprano
On Mon, 17 Mar 2008 05:28:19 -0700, castironpi wrote: > a tuple is a data > structure such which cannot contain a refrence to itself. >>> a = [] # a list >>> b = (a, None) # a tuple >>> a.append(b) >>> print b ([([...], None)], None) >>> b[0][0] is b True So, yes tuples can contain a refere

Re: lists v. tuples

2008-03-17 Thread Ninereeds
On Mar 17, 12:28 pm, [EMAIL PROTECTED] wrote: > > Why is the immutable form the default? > > Using a house definition from some weeks ago, a tuple is a data > structure such which cannot contain a refrence to itself. Can a > single expression refer to itself ever? Can't imagine why that feature

Re: lists v. tuples

2008-03-17 Thread Ninereeds
On Mar 17, 11:49 am, [EMAIL PROTECTED] wrote: > What are the considerations in choosing between: > >return [a, b, c] > > and > > return (a, b, c) # or return a, b, c > > Why is the immutable form the default? My understanding is that the immutable form is not the default - neither form is

Re: lists v. tuples

2008-03-17 Thread castironpi
On Mar 17, 6:49 am, [EMAIL PROTECTED] wrote: > What are the considerations in choosing between: > >    return [a, b, c] > > and > >     return (a, b, c) # or return a, b, c > > Why is the immutable form the default? Using a house definition from some weeks ago, a tuple is a data structure such whi

lists v. tuples

2008-03-17 Thread MartinRinehart
What are the considerations in choosing between: return [a, b, c] and return (a, b, c) # or return a, b, c Why is the immutable form the default? -- http://mail.python.org/mailman/listinfo/python-list