62 lines
1.3 KiB
Plaintext
62 lines
1.3 KiB
Plaintext
From: emile at fenx.com (Emile van Sebille)
|
|
Date: Sun, 16 May 1999 12:35:08 -0700
|
|
Subject: How to add a key:datum pair to the dictionary
|
|
References: <373f0ee9.30600632@news.tpnet.pl>
|
|
Message-ID: <PgF%2.411$VL2.63117@news.direcpc.com>
|
|
Content-Length: 1062
|
|
X-UID: 1720
|
|
|
|
You can use update:
|
|
|
|
>>> a={1:1,2:2}
|
|
>>> a.update({3:3})
|
|
>>> a
|
|
{3: 3, 2: 2, 1: 1}
|
|
|
|
|
|
--
|
|
|
|
Emile van Sebille
|
|
emile at fenx.com
|
|
-------------------
|
|
|
|
|
|
MK <mark_removethis_ at _removethis_btweng.krakow.pl> wrote in message
|
|
news:373f0ee9.30600632 at news.tpnet.pl...
|
|
> Hello everyone,
|
|
>
|
|
> I have stumbled across a stupid problem: how to add a pair to
|
|
> dictionary like
|
|
>
|
|
> {'mk': {'repetitions': 20, 'no match': 10}}
|
|
>
|
|
> I have not found the method for this anywhere in documentation.
|
|
> Dictionary is mutable, but neither Library Reference nor Language
|
|
> Reference give information on how to _add_ something to dictionary.
|
|
> It seems strange -- I mean, is creating dictionary and then changing
|
|
> items in it the only possible method of changing dictionary? Can it be
|
|
> enlarged?
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
> MK
|
|
>
|
|
>
|
|
> --------------------------------------------------
|
|
> Reality is something that does not disappear after
|
|
> you cease believing in it - VALIS, Philip K. Dick
|
|
> --------------------------------------------------
|
|
>
|
|
> Delete _removethis_ from address to email me
|
|
|
|
|
|
|
|
|
|
|
|
|