On Sep 9, 6:12 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
[big snip]
> In the interests of academia (although this isn't homework :)) I'll
> answer some of those questions:
Understanding your own requirements is , I would have thought, not
much to do with "academia" but a very practical id
On Sep 8, 10:20 am, John Machin <[EMAIL PROTECTED]> wrote:
> On Sep 8, 10:47 am, MK Bernard <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Sep 7, 3:37 pm, John Machin <[EMAIL PROTECTED]> wrote:
>
> > > On Sep 8, 7:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > > > Hello...
>
> > > > I have a
On Sep 8, 9:14 am, "James Mills" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 8, 2008 at 8:59 AM, John Machin <[EMAIL PROTECTED]> wrote:
> > What do you mean by "this right"? Perhaps the Divine Right of OPs,
> > managers, examiners, business analysts, etc never to give a complete
> > spec up front and
On Sep 8, 10:47 am, MK Bernard <[EMAIL PROTECTED]> wrote:
> On Sep 7, 3:37 pm, John Machin <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Sep 8, 7:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > > Hello...
>
> > > I have a dict of key/values and I want to change the keys in it, based
> > >
On Sep 7, 3:37 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Sep 8, 7:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello...
>
> > I have a dict of key/values and I want to change the keys in it, based
> > on another mapping dictionary. An example follows:
>
> > MAPPING_DICT = {
On Mon, Sep 8, 2008 at 8:59 AM, John Machin <[EMAIL PROTECTED]> wrote:
> What do you mean by "this right"? Perhaps the Divine Right of OPs,
> managers, examiners, business analysts, etc never to give a complete
> spec up front and never to contemplate the consequences of Murphy's
> Law?
Now you're
On Sun, 07 Sep 2008 15:59:52 -0700, John Machin wrote:
> On Sep 8, 8:42 am, "James Mills" <[EMAIL PROTECTED]> wrote:
>> On Mon, Sep 8, 2008 at 8:37 AM, John Machin <[EMAIL PROTECTED]>
>> wrote:
>
>> > There seems to be an implicit assumption in the answers so far that
>> > your mapping is a 1:1 m
On Sep 8, 8:42 am, "James Mills" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 8, 2008 at 8:37 AM, John Machin <[EMAIL PROTECTED]> wrote:
> > There seems to be an implicit assumption in the answers so far that
> > your mapping is a 1:1 mapping of all possible input keys.
>
> > If it doesn't include all
On Mon, Sep 8, 2008 at 8:37 AM, John Machin <[EMAIL PROTECTED]> wrote:
> Is this homework?
I hope it's not - or I'll be quite annoyed :)
> There seems to be an implicit assumption in the answers so far that
> your mapping is a 1:1 mapping of all possible input keys.
>
> If it doesn't include all
On Sep 8, 7:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello...
>
> I have a dict of key/values and I want to change the keys in it, based
> on another mapping dictionary. An example follows:
>
> MAPPING_DICT = {
> 'a': 'A',
> 'b': 'B',
>
> }
>
> my_dict = {
> 'a': '1',
>
En Sun, 07 Sep 2008 18:51:32 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
escribió:
> I have a dict of key/values and I want to change the keys in it, based
> on another mapping dictionary. An example follows:
>
> MAPPING_DICT = {
> 'a': 'A',
> 'b': 'B',
> }
>
> my_dict = {
> 'a': '1'
Hi,
There is "never" a "clever" way
of doing anything, but:
$ cat test.py
MAPPING_DICT = {'a': 'A','b': 'B',}
my_dict = {'a': '1','b': '2'}
my_dict = dict((MAPPING_DICT[k], my_dict[k]) for k in my_dict)
print my_dict
$ python test.py
{'A': '1', 'B': '2'}
$
That should do the trick.
cheers
James
[EMAIL PROTECTED] wrote:
Is there a clever way to do this, or should I loop through both,
essentially creating a brand new dict?
since none of your dictionaries contain the keys you want in the final
dictionary, creating a brand new dict sounds pretty clever to me.
--
http://mail.python.o
On Sep 7, 2:51 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello...
>
> I have a dict of key/values and I want to change the keys in it, based
> on another mapping dictionary. An example follows:
>
> MAPPING_DICT = {
> 'a': 'A',
> 'b': 'B',
>
> }
>
> my_dict = {
> 'a': '1',
>
On Sun, 07 Sep 2008 14:51:32 -0700, [EMAIL PROTECTED] wrote:
> MAPPING_DICT = {
> 'a': 'A',
> 'b': 'B',
> }
>
> my_dict = {
> 'a': '1',
> 'b': '2'
> }
>
> I want the finished my_dict to look like:
>
> my_dict = {
> 'A': '1',
> 'B': '2'
> }
>
> Whereby the keys in the or
15 matches
Mail list logo