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
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 tuple
[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 worked just
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:
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
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:4] ; 7, 8 following 6 so
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):
... if i==0:
...
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
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 version uses a
[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 consecutive numbers
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 without
[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 so on)
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 following 6 so
[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 so on)
i
[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 =
[6:9], and so
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]
--
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]
...
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:
... yield [tmp, valinc]
...
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
valinc
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:
...tmp =
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, so 3 = [3:4] ; 7, 8
[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 =
[6:9], and so
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:4] ; 7, 8
23 matches
Mail list logo