[EMAIL PROTECTED] wrote:
acc = []# accumulator ;)
for line in fileinput.input():
if condition(line):
if acc:#1
doSomething(acc)#1
acc = []
else:
acc.append(line)
if acc:#2
doSomething(acc)#2
Looks like you'd be better
On 2 Dec 2005 18:34:12 -0800, [EMAIL PROTECTED] wrote:
Bengt Richter wrote:
It looks to me like itertools.groupby could get you close to what you want,
e.g., (untested)
Ah, groupby. The generic string.split() equivalent. But the doc said
the input needs to be sorted.
seq =
Bengt Richter wrote:
On 2 Dec 2005 18:34:12 -0800, [EMAIL PROTECTED] wrote:
Bengt Richter wrote:
It looks to me like itertools.groupby could get you close to what you want,
e.g., (untested)
Ah, groupby. The generic string.split() equivalent. But the doc said
the input needs to be
Jeffrey Schwab wrote:
[EMAIL PROTECTED] wrote:
hello,
i often encounter something like:
acc = []# accumulator ;)
for line in fileinput.input():
if condition(line):
if acc:#1
doSomething(acc)#1
acc = []
else:
acc.append(line)
On 3 Dec 2005 03:28:19 -0800, [EMAIL PROTECTED] wrote:
Bengt Richter wrote:
On 2 Dec 2005 18:34:12 -0800, [EMAIL PROTECTED] wrote:
Bengt Richter wrote:
It looks to me like itertools.groupby could get you close to what you
want,
e.g., (untested)
Ah, groupby. The generic
On 2 Dec 2005 17:08:02 -0800, [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
hello,
i'm wondering how people from here handle this, as i often encounter
something like:
acc = []# accumulator ;)
for line in fileinput.input():
if condition(line):
if acc:#1
On 2 Dec 2005 16:45:38 -0800,
[EMAIL PROTECTED] wrote:
hello,
i'm wondering how people from here handle this, as i often encounter
something like:
acc = []# accumulator ;)
for line in fileinput.input():
if condition(line):
if acc:#1
doSomething(acc)#1
Bengt Richter wrote:
It looks to me like itertools.groupby could get you close to what you want,
e.g., (untested)
Ah, groupby. The generic string.split() equivalent. But the doc said
the input needs to be sorted.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
hello,
i'm wondering how people from here handle this, as i often encounter
something like:
acc = []# accumulator ;)
for line in fileinput.input():
if condition(line):
if acc:#1
doSomething(acc)#1
acc = []
else: