Raymond Hettinger wrote:
> [Steven Bethard]
>
>>>I have a list of strings that looks something like:
>>>lst = ['0', '0', '(*)', 'O', '(*', '*', '(*', '*))', '((*', '*)', '*)']
>
> . . .
>
>>>I want the indices:
>>>(2, 2), (4, 7), (6, 7), (8, 9) and (8, 10)
>
> opener_stack = []
> for i, elem i
Peter Otten wrote:
> I think no amount of testing will give these strange people confidence.
> "Proof" is the magic word here.
Some would maybe be satisfied if your tests cover the whole set of input.
When that's possible, that may be useless. But that's not a matter to
bother them with. ;)
(An
tiissa wrote:
> Not tested but confident is an oxymoron for mathemtaticians.
I think no amount of testing will give these strange people confidence.
"Proof" is the magic word here.
Peter
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
> tiissa wrote:
>>Disclaimer: not tested further than example above (but confident).
>
> Not tested but confident should be an oxymoron for a programmer.
Not tested but confident is an oxymoron for mathemtaticians.
Programmers know better than that, they leave bugs in their cod
tiissa wrote:
> Steven Bethard wrote:
>> (2) Does anyone see an easier/clearer/simpler[1] way of doing this?
>
> I'd personnally extract the parenthesis then zip the lists of indices.
> In short:
>
> >>> def indices(mylist):
> ... lopen=reduce(list.__add__, [[i]*s.count('(') for i,s in
>
[Steven Bethard]
>> I have a list of strings that looks something like:
>> lst = ['0', '0', '(*)', 'O', '(*', '*', '(*', '*))', '((*', '*)', '*)']
. . .
>> I want the indices:
>> (2, 2), (4, 7), (6, 7), (8, 9) and (8, 10)
opener_stack = []
for i, elem in enumerate(lst):
for c in elem:
tiissa wrote:
> I'd personnally extract the parenthesis then zip the lists of indices.
> In short:
>
> >>> def indices(mylist):
> ... lopen=reduce(list.__add__, [[i]*s.count('(') for i,s in
> enumerate(mylist)],[])
> ... lclose=reduce(list.__add__, [[i]*s.count(')') for i,s in
> enume
Steven Bethard wrote:
> (2) Does anyone see an easier/clearer/simpler[1] way of doing this?
I'd personnally extract the parenthesis then zip the lists of indices.
In short:
>>> def indices(mylist):
... lopen=reduce(list.__add__, [[i]*s.count('(') for i,s in
enumerate(mylist)],[])
...
I have a list of strings that looks something like:
lst = ['0', '0', '(*)', 'O', '(*', '*', '(*', '*))', '((*', '*)', '*)']
The parentheses in the labels indicate where an "annotation" starts and
ends. So for example, the label '(*)' at index 2 of the list means that
I have an annotation at (2