Re: Tuples vs Lists: Semantic difference (was: Extract String From Enclosing Tuple)

2007-03-01 Thread MonkeeSage
On Mar 1, 5:02 am, [EMAIL PROTECTED] wrote: > I don't know Ruby, but I think it allows such purposes with a freezing > function. In ruby all objects can be frozen (freeze is a method on Object, from which all other objects derive), not just Arrays (Arrays == lists in python; ruby has no built-in c

Re: Extract String From Enclosing Tuple

2007-03-01 Thread rshepard
On 2007-02-28, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: import itertools tuple(itertools.chain((t[0], t2[0].encode('ascii')), t[2:])) > ('eco', 'Roads', 0.073969887301348305) Steven, As suggested in the previous article, I handled it where the values are read from the list retrie

Re: Tuples vs Lists: Semantic difference (was: Extract String From Enclosing Tuple)

2007-03-01 Thread bearophileHUGS
George Sakkis, I agree with the things you say. Sometimes you may have a sequence of uniform data with unknown len (so its index doesn't have semantic meaning). You may want to use it as dict key, so you probably use a tuple meant as just an immutable list. I don't know Ruby, but I think it allows

Re: Tuples vs Lists: Semantic difference (was: Extract String From Enclosing Tuple)

2007-02-28 Thread George Sakkis
On Feb 28, 10:45 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Bjoern Schliessmann <[EMAIL PROTECTED]> writes: > > I know tuples as immutable lists ... > > That's a common misconception. And this catch phrase, "that's a common misconception", is a common aping of the BDFL's take on this. As severa

Tuples vs Lists: Semantic difference (was: Extract String From Enclosing Tuple)

2007-02-28 Thread Ben Finney
Bjoern Schliessmann <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > > A tuple implies a meaning associated with each position in the > > sequence (like a record with a positional meaning for each field), > > a list implies the opposite (a sequence with order but not meaning > > associated with

Re: Extract String From Enclosing Tuple

2007-02-28 Thread Bjoern Schliessmann
Ben Finney wrote: > A tuple implies a meaning associated with each position in the > sequence (like a record with a positional meaning for each field), > a list implies the opposite (a sequence with order but not meaning > associated with each position). Explain. I know tuples as immutable lists

Re: Extract String From Enclosing Tuple

2007-02-28 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > orders = ( > [...] > ) > > order_items = ( > [...] > ) For clarity, these sequences of records should be lists (with each item being a tuple containing the record fields), not tuples. A tuple implies a meaning associated with each position in the sequence

Re: Extract String From Enclosing Tuple

2007-02-28 Thread Ben Finney
[EMAIL PROTECTED] writes: > Data are assembled for writing to a database table. A > representative tuple looks like this: > > ('eco', "(u'Roads',)", 0.073969887301348305) You refer to the second item as "a tuple" later, but it's not; it's now just a string (not even a unicode string). Whatever

Re: Extract String From Enclosing Tuple

2007-02-28 Thread attn . steven . kuo
On Feb 28, 12:40 pm, [EMAIL PROTECTED] wrote: > I'm a bit embarrassed to have to ask for help on this, but I'm not finding > the solution in the docs I have here. > > Data are assembled for writing to a database table. A representative tuple > looks like this: > > ('eco', "(u'Roads',)", 0.07396

Re: Extract String From Enclosing Tuple

2007-02-28 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I'm a bit embarrassed to have to ask for help on this, but I'm not finding > the solution in the docs I have here. > > Data are assembled for writing to a database table. A representative tuple > looks like this: > > ('eco', "(u'Roads',)", 0.073969887301348305)

Extract String From Enclosing Tuple

2007-02-28 Thread rshepard
I'm a bit embarrassed to have to ask for help on this, but I'm not finding the solution in the docs I have here. Data are assembled for writing to a database table. A representative tuple looks like this: ('eco', "(u'Roads',)", 0.073969887301348305) Pysqlite doesn't like the format of the mi