[EMAIL PROTECTED] wrote:
>> ... _, first_n = group[0]
>
> what is the meaning of the underscore "_" ? is it a special var ? or
> should it be readed as a way of unpacking a tuple in a non useful var ?
> like
>
> lost, first_n = group[0]
Yep, it's just another name. "lost" would have wo
Yup! '_' is just used as a dummy. Its a pretty common idiom. There's
nothing special about that variable.
[EMAIL PROTECTED] wrote:
> Hello
>
>> ... _, first_n = group[0]
>
> what is the meaning of the underscore "_" ? is it a special var ? or
> should it be readed as a way of unpacking a
Hello
> ... _, first_n = group[0]
what is the meaning of the underscore "_" ? is it a special var ? or
should it be readed as a way of unpacking a tuple in a non useful var ?
like
lost, first_n = group[0]
best regards.
--
http://mail.python.org/mailman/listinfo/python-list
Gerard Flanagan wrote:
> [EMAIL PROTECTED] wrote:
>> hello,
>>
>> i'm looking for a way to have a list of number grouped by consecutive
>> interval, after a search, for example :
>>
>> [3, 6, 7, 8, 12, 13, 15]
>>
>> =>
>>
>> [[3, 4], [6,9], [12, 14], [15, 16]]
>>
>> (6, not following 3, so 3 => [3:
[EMAIL PROTECTED] wrote:
> hello,
>
> i'm looking for a way to have a list of number grouped by consecutive
> interval, after a search, for example :
>
> [3, 6, 7, 8, 12, 13, 15]
>
> =>
>
> [[3, 4], [6,9], [12, 14], [15, 16]]
>
> (6, not following 3, so 3 => [3:4] ; 7, 8 following 6 so 6, 7, 8 =>
>
thanks to all !
my version was far less clever/long thant the one you posted, i'm going
to examine all these with much interest, and learn...
best regards.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> i'm looking for a way to have a list of number grouped by consecutive
> interval, after a search, for example :
>
> [3, 6, 7, 8, 12, 13, 15]
>
> =>
>
> [[3, 4], [6,9], [12, 14], [15, 16]]
Know your itertools. From the examples section[1]:
"""
# Find runs of consecut
In article <[EMAIL PROTECTED]>,
Paddy <[EMAIL PROTECTED]> wrote:
>
>John Machin wrote:
>> On 2/06/2006 8:36 AM, Paddy wrote:
>
>>
>> Oh the siren call of every new feature in the language!
>> enumerate() just to get a first-time test, and then botch it??
>>
>> Read the following; the replacement ve
John Machin wrote:
> On 2/06/2006 8:36 AM, Paddy wrote:
>
> Oh the siren call of every new feature in the language!
> enumerate() just to get a first-time test, and then botch it??
>
> Read the following; the replacement version uses a simple old-fashioned
> inelegant flag, works with an empty se
Jim Segrave wrote:
> In article <[EMAIL PROTECTED]>,
> Paddy <[EMAIL PROTECTED]> wrote:
> >
> >What I ran was more like the version below, but i did a quick
> >separation of the line that has the ';' in it and goofed.
> >
> def interv2(inlist):
> >... for i,val in enumerate(inlist):
> >...
Gerard Flanagan wrote:
> [EMAIL PROTECTED] wrote:
> > hello,
> >
> > i'm looking for a way to have a list of number grouped by consecutive
> > interval, after a search, for example :
> >
> > [3, 6, 7, 8, 12, 13, 15]
> >
> > =>
> >
> > [[3, 4], [6,9], [12, 14], [15, 16]]
> >
> > (6, not following 3
[EMAIL PROTECTED] wrote:
> hello,
>
> i'm looking for a way to have a list of number grouped by consecutive
> interval, after a search, for example :
>
> [3, 6, 7, 8, 12, 13, 15]
>
> =>
>
> [[3, 4], [6,9], [12, 14], [15, 16]]
>
> (6, not following 3, so 3 => [3:4] ; 7, 8 following 6 so 6, 7, 8 =>
>
On 2/06/2006 8:36 AM, Paddy wrote:
> [EMAIL PROTECTED] wrote:
>> hello,
>>
>> i'm looking for a way to have a list of number grouped by consecutive
>> interval, after a search, for example :
>>
>> [3, 6, 7, 8, 12, 13, 15]
>>
>> =>
>>
>> [[3, 4], [6,9], [12, 14], [15, 16]]
>>
>> (6, not following 3,
In article <[EMAIL PROTECTED]>,
Paddy <[EMAIL PROTECTED]> wrote:
>
>What I ran was more like the version below, but i did a quick
>separation of the line that has the ';' in it and goofed.
>
def interv2(inlist):
>...for i,val in enumerate(inlist):
>...if i==0:
>...
In article <[EMAIL PROTECTED]>,
Paddy <[EMAIL PROTECTED]> wrote:
>I did a little re-arranging of the generator version:
>
>def interv3(inlist):
>tmp = inlist[0]
>valinc = tmp+1
>for val in inlist[1:]:
>if val != valinc:
>yield [tmp, valinc];
>tmp = val
>
Jim Segrave wrote:
> In article <[EMAIL PROTECTED]>,
> Paddy <[EMAIL PROTECTED]> wrote:
> >=== interv2 ===
> def interv2(inlist):
> >... for i,val in enumerate(inlist):
> >... if i==0:
> >... tmp = val
> >... elif val != valinc:
> >... yiel
In article <[EMAIL PROTECTED]>,
Paddy <[EMAIL PROTECTED]> wrote:
>=== interv2 ===
def interv2(inlist):
>...for i,val in enumerate(inlist):
>...if i==0:
>...tmp = val
>...elif val != valinc:
>...yield [tmp, valinc]
>...
I did a little re-arranging of the generator version:
def interv3(inlist):
tmp = inlist[0]
valinc = tmp+1
for val in inlist[1:]:
if val != valinc:
yield [tmp, valinc];
tmp = val
valinc = val+1
yield [tmp, valinc]
--
http://mail.python.org/m
[EMAIL PROTECTED] wrote:
> hello,
>
> i'm looking for a way to have a list of number grouped by consecutive
> interval, after a search, for example :
>
> [3, 6, 7, 8, 12, 13, 15]
>
> =>
>
> [[3, 4], [6,9], [12, 14], [15, 16]]
>
> (6, not following 3, so 3 => [3:4] ; 7, 8 following 6 so 6, 7, 8 =>
>
[EMAIL PROTECTED] wrote:
> i'm looking for a way to have a list of number grouped by consecutive
> interval, after a search, for example :
>
> [3, 6, 7, 8, 12, 13, 15]
>
> =>
>
> [[3, 4], [6,9], [12, 14], [15, 16]]
>
> (6, not following 3, so 3 => [3:4] ; 7, 8 following 6 so 6, 7, 8 =>
> [6:9], and
In article <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> wrote:
>hello,
>
>i'm looking for a way to have a list of number grouped by consecutive
>interval, after a search, for example :
>
>[3, 6, 7, 8, 12, 13, 15]
>
>=>
>
>[[3, 4], [6,9], [12, 14], [15, 16]]
>
>(6, not following 3, so 3 => [3:4] ; 7, 8
[EMAIL PROTECTED] wrote:
> i'm looking for a way to have a list of number grouped by consecutive
> interval, after a search, for example :
>
> [3, 6, 7, 8, 12, 13, 15]
>
> =>
>
> [[3, 4], [6,9], [12, 14], [15, 16]]
>
> (6, not following 3, so 3 => [3:4] ; 7, 8 following 6 so 6, 7, 8 =>
> [6:9]
hello,
i'm looking for a way to have a list of number grouped by consecutive
interval, after a search, for example :
[3, 6, 7, 8, 12, 13, 15]
=>
[[3, 4], [6,9], [12, 14], [15, 16]]
(6, not following 3, so 3 => [3:4] ; 7, 8 following 6 so 6, 7, 8 =>
[6:9], and so on)
i was able to to it withou
23 matches
Mail list logo