On 2011-11-26 03:49, lina wrote:
for k, v in occurence.items():
print(v,k)
292 frozenset({66, 69})
222 frozenset({24, 27})
How can I let the result like:
292 {66,69}
222 {24,27}
don't output the frozenset
If you want to use your own output format you have to provide
On Sat, Nov 26, 2011 at 12:49 AM, Andreas Perstinger
wrote:
> On 2011-11-25 13:40, lina wrote:
>>
>> On Fri, Nov 25, 2011 at 7:19 PM, Steven D'Aprano
>> wrote:
>>>
>>> f = open("some file")
>>> dehydrons = {}
>>> occurrence = {}
>>> pairs = {}
>>> for line in f.readlines():
>>> parts = l
On 2011-11-25 13:40, lina wrote:
On Fri, Nov 25, 2011 at 7:19 PM, Steven D'Aprano wrote:
f = open("some file")
dehydrons = {}
occurrence = {}
pairs = {}
for line in f.readlines():
parts = line.split()
# convert to ints
parts = [int(s) for s in parts]
pair = frozenset(pa
On Fri, Nov 25, 2011 at 7:19 PM, Steven D'Aprano wrote:
> lina wrote:
>>
>> On Fri, Nov 25, 2011 at 5:06 PM, Steven D'Aprano
>> wrote:
>
>>> pair = frozenset(('66', '69'))
>>> pairs[pair] = pairs.get(pair, 0) + value
>>
>> I don't get this "pairs.get" part.
>
> The "get" method does a look-up on
On 25/11/11 08:41, lina wrote:
pairs
{('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
such as here ('66', '69') and ('69', '66') is one key,
I wanna keep only one and add the value of those two keys, above is a
very simple example:
here is the (failed) code:
for k, v in pair
lina wrote:
On Fri, Nov 25, 2011 at 5:06 PM, Steven D'Aprano wrote:
pair = frozenset(('66', '69'))
pairs[pair] = pairs.get(pair, 0) + value
I don't get this "pairs.get" part.
The "get" method does a look-up on a dict, but instead of failing if the
key is missing, it returns a default val
for key, value in pairs.items():
if key[::-1] in pairs.keys() and pairs[key] != 0:
pairs[key] += pairs[key[::-1]]
pairs[key[::-1]]=0
for k, v in pairs.items():
if v != 0:
print(v,k)
Now very trivial, but works.
#!/usr/bin/python3
dehydrons={}
pairs={}
#frozen set way pairs
fs_pairs={}
occurence={}
total=0
dictionary={}
candidate_dehydron={}
if __name__=="__main__":
with open("dehydron_refined_data_18.txt","r") as f:
for line in f.readlines():
parts=line.split()
#pai
On Fri, Nov 25, 2011 at 5:19 PM, Christian Witts wrote:
> On 2011/11/25 11:15 AM, lina wrote:
>
> On Fri, Nov 25, 2011 at 5:05 PM, Christian Witts
> wrote:
>
> On 2011/11/25 10:41 AM, lina wrote:
>
> pairs
>
> {('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
>
>
> such as here ('66', '69')
On Fri, Nov 25, 2011 at 5:06 PM, Steven D'Aprano wrote:
> lina wrote:
>
> pairs
>>
>> {('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
>>
>>
>> such as here ('66', '69') and ('69', '66') is one key,
>>
>> I wanna keep only one and add the value of those two keys, above is a
>> very
On 2011/11/25 11:15 AM, lina wrote:
On Fri, Nov 25, 2011 at 5:05 PM, Christian Witts wrote:
On 2011/11/25 10:41 AM, lina wrote:
pairs
{('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
such as here ('66', '69') and ('69', '66') is one key,
I wanna keep only one and add the value of th
On Fri, Nov 25, 2011 at 5:05 PM, Christian Witts wrote:
> On 2011/11/25 10:41 AM, lina wrote:
>
> pairs
>
> {('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
>
>
> such as here ('66', '69') and ('69', '66') is one key,
>
> I wanna keep only one and add the value of those two keys, above is a
On 2011/11/25 10:41 AM, lina wrote:
pairs
{('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
such as here ('66', '69') and ('69', '66') is one key,
I wanna keep only one and add the value of those two keys, above is a
very simple example:
here is the (failed) code:
for k, v in
lina wrote:
pairs
{('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
such as here ('66', '69') and ('69', '66') is one key,
I wanna keep only one and add the value of those two keys, above is a
very simple example:
Which one do you want to keep?
If the order ('66', '69') is unimporta
>>> pairs
{('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25}
such as here ('66', '69') and ('69', '66') is one key,
I wanna keep only one and add the value of those two keys, above is a
very simple example:
here is the (failed) code:
for k, v in pairs.items():
if str(k
15 matches
Mail list logo