View Single Post
  #6   Spotlight this post!  
Unread 30-08-2010, 01:50
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 802
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Im doing something wrong here (python)

That's your issue. (assuming I'm internally evaluating that correctly...) Python is going to interpret that as an array, and then you are inserting that array into a list. Hence your double packed list.

I'd highly recommend learning how pickling works. It's very easy and better than using eval in that location.

Code:
#!/usr/bin/python
import pickle

filename = "p.txt"

f = open(filename, "w")
pickle.dump({1:"a", 2:"b", 3:"c"}, f)
f.close()

f = open(filename, "r")
print pickle.load(f)
f.close()
You could also edit the code to instead use += instead of append. That'll solve your problem as well, but still leaves a security vulnerability.