2011/4/21 Darío Suárez Gracia dario.sua...@telefonica.net
Hi all,
I was trying to share a dictionary of dictionaries of arrays with Manager
from multiprocessing. Without multiprocessing the code works perfectly, but
with the current example the last print does not show the correct result
Hi all,
I was trying to share a dictionary of dictionaries of arrays with
Manager from multiprocessing. Without multiprocessing the code works
perfectly, but with the current example the last print does not show
the correct result.
Any hint?
Thanks,
Darío Suárez#!/usr/local/bin/python2.7
On Nov 9, 2:27 pm, Peter Otten __pete...@web.de wrote:
J Wolfe wrote:
I would like to sort this dictionary by the values of the inner
dictionary ‘ob’ key.
Python's built-in dictionary is unsorted by design.
mydict =
{’WILW1′: {’fx’: ‘8.1′, ‘obtime’: ‘2009-11-07 06:45:00′, ‘ob’:
J Wolfe wrote:
I would like to sort this dictionary by the values of the inner
dictionary ‘ob’ key.
Python's built-in dictionary is unsorted by design.
mydict =
{’WILW1′: {’fx’: ‘8.1′, ‘obtime’: ‘2009-11-07 06:45:00′, ‘ob’: ‘6.9′},
‘GRRW1′: {’fx’: ‘12.8′, ‘obtime’: ‘2009-11-07 04:15:00′,
On Mon, 09 Nov 2009 06:02:09 -0800, J Wolfe wrote:
Hi,
I would like to sort this dictionary by the values of the inner
dictionary ‘ob’ key.
You can't sort dictionaries in Python, because they are unordered hash
tables. Giving up the ability to store items in order is one of the
things
I've been using irclib to write a simple irc bot, and I was running into
some difficulties with pickle. Upon some experimentation with pdb, I found
that pickle.load() doesn't load *all* of the data the _first_ time it's
called.
For instance, I have this dictionary pickled:
{'xiong_chiamiov':
On Sun, 2009-02-22 at 16:15 -0800, James Pearson wrote:
I've been using irclib to write a simple irc bot, and I was running
into some difficulties with pickle. Upon some experimentation with
pdb, I found that pickle.load() doesn't load *all* of the data the
_first_ time it's called.
For
Ah, thank you, you explained that quite well and opened my eyes to some
things I very much need to improve in my code. I'll keep those
list-etiquette things in mind next time.
On Sun, Feb 22, 2009 at 5:10 PM, Albert Hopkins mar...@letterboxes.orgwrote:
On Sun, 2009-02-22 at 16:15 -0800, James
On Mon, 10 Dec 2007 23:51:00 -0800, kettle wrote:
On Dec 10, 6:58 pm, Peter Otten [EMAIL PROTECTED] wrote:
Well, there's also dict.setdefault()
pairs = [ab, ab, ac, bc]
outer = {}
for a, b in pairs:
... inner = outer.setdefault(a, {})
... inner[b] = inner.get(b, 0) + 1
...
On Dec 9, 9:35 am, kettle [EMAIL PROTECTED] wrote:
Hi,
I'm wondering what the best practice is for creating an extensible
dictionary-of-dictionaries in python?
In perl I would just do something like:
my %hash_of_hashes;
for(my $i=0;$i10;$i++){
for(my $j=0;$j10;$j
kettle wrote:
On Dec 9, 5:49 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sun, 09 Dec 2007 00:35:18 -0800, kettle wrote:
Hi,
I'm wondering what the best practice is for creating an extensible
dictionary-of-dictionaries in python?
In perl I would just do something like
On Dec 10, 6:58 pm, Peter Otten [EMAIL PROTECTED] wrote:
kettle wrote:
On Dec 9, 5:49 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sun, 09 Dec 2007 00:35:18 -0800, kettle wrote:
Hi,
I'm wondering what the best practice is for creating an extensible
dictionary
On Dec 10, 6:58 pm, Peter Otten [EMAIL PROTECTED] wrote:
kettle wrote:
On Dec 9, 5:49 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sun, 09 Dec 2007 00:35:18 -0800, kettle wrote:
Hi,
I'm wondering what the best practice is for creating an extensible
dictionary
Hi,
I'm wondering what the best practice is for creating an extensible
dictionary-of-dictionaries in python?
In perl I would just do something like:
my %hash_of_hashes;
for(my $i=0;$i10;$i++){
for(my $j=0;$j10;$j++){
${$hash_of_hashes{$i}}{$j} = int(rand(10));
}
}
but it seems
On Sun, 09 Dec 2007 00:35:18 -0800, kettle wrote:
Hi,
I'm wondering what the best practice is for creating an extensible
dictionary-of-dictionaries in python?
In perl I would just do something like:
my %hash_of_hashes;
for(my $i=0;$i10;$i++){
for(my $j=0;$j10;$j
On Dec 9, 5:49 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sun, 09 Dec 2007 00:35:18 -0800, kettle wrote:
Hi,
I'm wondering what the best practice is for creating an extensible
dictionary-of-dictionaries in python?
In perl I would just do something like:
my
Hi,
I have the following -
messagesReceived = dict.fromkeys((one,two), {})
messagesReceived['one']['123'] = 1
messagesReceived['two']['121'] = 2
messagesReceived['two']['124'] = 4
This gives:
{'two': {'121': 2, '123': 1, '124': 4}, 'one': {'121':
2, '123': 1,
On 5 Mar 2007 02:22:24 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hi,
I have the following -
messagesReceived = dict.fromkeys((one,two), {})
This will create a dictionary messagesReceived, with all the keys
referring to *same instance* of the (empty) dictionary.
( try:
In [EMAIL PROTECTED], bg_ie wrote:
What am I doing wrong?
`dict.fromkeys()` stores the given object for all keys, so you end up with
the *same* dictionary for 'one' and 'two'.
In [18]: a = dict.fromkeys((one,two), {})
In [19]: a
Out[19]: {'two': {}, 'one': {}}
In [20]: a['one']['x'] = 42
In
On 5 Mar, 11:45, Amit Khemka [EMAIL PROTECTED] wrote:
On 5 Mar 2007 02:22:24 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hi,
I have the following -
messagesReceived = dict.fromkeys((one,two), {})
This will create a dictionary messagesReceived, with all the keys
referring to
On Mar 5, 11:22 am, [EMAIL PROTECTED] wrote:
messagesReceived = dict.fromkeys((one,two), {})
This creates two references to just *one* instance of empty
dictionary.
I'd do it like:
messagesReceived = dict([(key, {}) for key in (one,two)])
--
Bart Ogryczak [EMAIL PROTECTED] wrote:
On Mar 5, 11:22 am, [EMAIL PROTECTED] wrote:
messagesReceived = dict.fromkeys((one,two), {})
This creates two references to just *one* instance of empty
dictionary.
I'd do it like:
messagesReceived = dict([(key, {}) for key in (one,two)])
22 matches
Mail list logo