Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python acting weird

Reply
Thread Tools

Python acting weird

 
 
Westly Ward
Guest
Posts: n/a
 
      07-26-2010
x = {"type":"folder", "name":"sonicbot", "data":[{"type":"folder",
"name":"SonicMail", "data":[{"type":"file", "name":"bbcode.py",
"compressed":False, "contents":"blahblahfilecontents"}]}]}
print x
def setindict(dictionary, keys, value) :
if len(keys) == 1 :
if keys[0].isdigit() and int(keys[0]) == len(dictionary) :
dictionary.append(keys[0])
else :
dictionary[keys[0]] = value
else :
dictionary[keys[0]] = setindict(dictionary[keys[0]], keys[1:], value)
return dictionary
a = x.copy()

print id(a), id(x)
y = setindict(a, ["data", 0, "data", 0, "compressed"], True)
if y == x :
print True

else :
print False
print x
print a

How are x and a are ending up the same? I would think .copy() would
make it completely seperate.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET acting weird in Windows 2003 server David ASP .Net 5 04-21-2005 04:22 PM
Firefox acting weird maradcliff@UNLISTED.com Firefox 4 11-15-2004 03:16 AM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-20-2004 12:07 PM
Hard drive really acting weird Will Smith Computer Support 13 12-18-2003 03:33 AM
NS7.1 -- busted Moz registry? JMC acting weird... Gordon S. Hlavenka Firefox 1 10-31-2003 02:58 PM



Advertisments