Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51661

Re: binary key in dictionary

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!panix!gordon
From John Gordon <gordon@panix.com>
Newsgroups comp.lang.python
Subject Re: binary key in dictionary
Date Wed, 31 Jul 2013 14:26:27 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 23
Message-ID <ktb6qj$b4g$1@reader1.panix.com> (permalink)
References <9004a556-958f-4d1d-81a7-4d1b731348c5@googlegroups.com>
NNTP-Posting-Host panix2.panix.com
X-Trace reader1.panix.com 1375280787 11408 166.84.1.2 (31 Jul 2013 14:26:27 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Wed, 31 Jul 2013 14:26:27 +0000 (UTC)
User-Agent nn/6.7.3
Xref csiph.com comp.lang.python:51661

Show key headers only | View raw


In <9004a556-958f-4d1d-81a7-4d1b731348c5@googlegroups.com> cerr <ron.eggler@gmail.com> writes:

> Traceback (most recent call last):
>   File "gateway.py", line 2485, in <module>
>     main()
>   File "gateway.py", line 2459, in main
>     cloud_check()
>   File "gateway.py", line 770, in cloud_check
>     gnstr_dict[src] = gn_from_cloud(curr_mac)
>   File "gateway.py", line 2103, in gn_from_cloud
>     tmpgndict[binmac] += "HELLO"
> KeyError: '\x04\xeeu'

You're not assigning to tmpgndict[binmac]; you're appending to it.  This
requires that tmpgndict[binmac] already exists, which it does not.

Make sure that tmpgndict[binmac] exists before you try appending to it.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

binary key in dictionary cerr <ron.eggler@gmail.com> - 2013-07-30 13:29 -0700
  Re: binary key in dictionary Gary Herron <gary.herron@islandtraining.com> - 2013-07-30 13:44 -0700
  Re: binary key in dictionary John Gordon <gordon@panix.com> - 2013-07-31 14:26 +0000

csiph-web