[cse491] Dictionaries

C. Titus Brown ctb at msu.edu
Mon Sep 28 20:16:12 PDT 2009


On Mon, Sep 28, 2009 at 11:09:45PM -0400, Joseph Christian Blossom wrote:
> Hello Titus,So, I've attempted to do a dictionary using the socket object as
> a key, and the datareceived string as the value... however I keep getting
> errors doing this... from what I've been reading the key of a dictionary
> must be non-mutable. Socket objects are mutable, correct? Wouldn't this make
> your suggestion not work?

Heh, you had me worried there for a sec, but it works for me:

--
s = socket.socket()
d = {}

s.connect( ('teckla.idyll.org', 25) )
d[s] = 'foo'
--

--titus
-- 
C. Titus Brown, ctb at msu.edu



More information about the cse491-fall-2009 mailing list