Re: Remove comma from tuples in python.

2014-02-23 Thread Cameron Simpson
On 21Feb2014 09:32, Roy Smith wrote: > In article , > Peter Otten <__pete...@web.de> wrote: > > [x*x for (x,) in lst] > > > > [paraphrasing...] can be better written as: > > > > [x*x for [x] in items] > > I'm torn between, "Yes, the second form is distinctly easier to read" > and, "If you think

Re: Remove comma from tuples in python.

2014-02-21 Thread Tim Chase
On 2014-02-21 09:48, Travis Griggs wrote: > I’ve used the comma form with struct.unpack() frequently: > > count, = struct.unpack(‘!I’, self.packet) This is *especially* one of those places I want extra parens to make sure I see what's happening. I've been stung too many times by the easy-to-miss

Re: Remove comma from tuples in python.

2014-02-21 Thread Travis Griggs
On Feb 21, 2014, at 6:32 AM, Roy Smith wrote: > In article , > Peter Otten <__pete...@web.de> wrote: > > >> [x*x for (x,) in lst] >> >> [paraphrasing...] can be better written as: >> >> [x*x for [x] in items] > > I'm torn between, "Yes, the second form is distinctly easier to read" > and,

Re: Remove comma from tuples in python.

2014-02-21 Thread Roy Smith
In article , Peter Otten <__pete...@web.de> wrote: > [x*x for (x,) in lst] > > [paraphrasing...] can be better written as: > > [x*x for [x] in items] I'm torn between, "Yes, the second form is distinctly easier to read" and, "If you think the second form is easier to read, you're admitting yo

Re: Remove comma from tuples in python.

2014-02-21 Thread Peter Otten
Tim Chase wrote: > With the single-value tuple, I tend to find the parens make it more > readable, so I'd go with > > [x*x for (x,) in lst] Hardly ever seen in the wild, but unpacking works with [...], too: >>> items = zip(range(5)) >>> [x*x for [x] in items] [0, 1, 4, 9, 16] -- https://mai

Re: Remove comma from tuples in python.

2014-02-21 Thread Mark Lawrence
On 21/02/2014 08:27, Gary Herron wrote: A bit of notation, because I''m not sure we are communicating well here: A tuple is a Python data structure. It has no commas or parentheses. The *printing* of a Python tuple uses both for it's appearance on the output, but the tuple itself has no su

Re: Remove comma from tuples in python.

2014-02-21 Thread Tim Chase
On 2014-02-21 09:29, Alister wrote: > >>>> seriesxlist1 = ((0.0,), (0.01,), (0.02,)) > >>>> x2 = [x*x for (x,) in seriesxlist1] > > > > I tend to omit those parentheses and use just the comma: > > > >>>> x2 = [x*x for x, in seriesxlist1] > > I had not though of using unpacking

Re: Remove comma from tuples in python.

2014-02-21 Thread Alister
On Fri, 21 Feb 2014 11:13:30 +0200, Jussi Piitulainen wrote: > Gary Herron writes: > >> On 02/20/2014 10:49 PM, Jaydeep Patil wrote: >> > I am getting below tuple from excel. >> > How should i remove extra commas in each tuple to make it easy for >> > operations. >> > >> > tuples is: >> > seriesx

Re: Remove comma from tuples in python.

2014-02-21 Thread Jussi Piitulainen
Gary Herron writes: > On 02/20/2014 10:49 PM, Jaydeep Patil wrote: > > I am getting below tuple from excel. > > How should i remove extra commas in each tuple to make it easy for > > operations. > > > > tuples is: > > seriesxlist1 = ((0.0), (0.01), (0.02), (0.03), (0.04), (0.05), (0.06), > > (0.0

Re: Remove comma from tuples in python.

2014-02-21 Thread Gary Herron
On 02/20/2014 10:49 PM, Jaydeep Patil wrote: I am getting below tuple from excel. How should i remove extra commas in each tuple to make it easy for operations. tuples is: seriesxlist1 = ((0.0), (0.01), (0.02), (0.03), (0.04), (0.05), (0.06), (0.07), (0.08), (0.09), (0.1), (0.11)) please sug

Re: Remove comma from tuples in python.

2014-02-20 Thread Bernd Nawothnig
On 2014-02-21, Mircescu Andrei wrote: > vineri, 21 februarie 2014, 08:49:01 UTC+2, Jaydeep Patil a scris: >> I am getting below tuple from excel. >> >> How should i remove extra commas in each tuple to make it easy for >> operations. >> >> >> >> tuples is: >> >> seriesxlist1 = ((0.0), (0.01),

Re: Remove comma from tuples in python.

2014-02-20 Thread Stephane Wirtel
This is just a tuple of integers and not a tuple of tuples of integers, the parentheses around the number is just there for the evaluation. > On 21 févr. 2014, at 08:02 AM, Mircescu Andrei > wrote: > > vineri, 21 februarie 2014, 08:49:01 UTC+2, Jaydeep Patil a scris: >> I am getting below tu

Re: Remove comma from tuples in python.

2014-02-20 Thread Mircescu Andrei
vineri, 21 februarie 2014, 08:49:01 UTC+2, Jaydeep Patil a scris: > I am getting below tuple from excel. > > How should i remove extra commas in each tuple to make it easy for operations. > > > > tuples is: > > seriesxlist1 = ((0.0), (0.01), (0.02), (0.03), (0.04), (0.05), (0.06), > (0.07), (

Remove comma from tuples in python.

2014-02-20 Thread Jaydeep Patil
I am getting below tuple from excel. How should i remove extra commas in each tuple to make it easy for operations. tuples is: seriesxlist1 = ((0.0), (0.01), (0.02), (0.03), (0.04), (0.05), (0.06), (0.07), (0.08), (0.09), (0.1), (0.11)) please suggest me solution. Regards jay -- https://ma