On Aug 12, 4:53 pm, Tony <tonyl7...@gmail.com> wrote:
> This is more of a python question but its in my Django project.  I am
> reading a unicode object and an integer from a database into a
> dictionnary and storing that in a pickled file.  Ive confirmed the
> dictionary is done correctly because i print it out from the pickled
> file later to check.  I also cast the unicode object as a string
> before making it the key corresponding to an integer in the
> dictionary.  This also appears to work.  However, when I try to use an
> if statement to check if a key is in the dictionary I get this error:
> "sequence item 0: expected string, int found".  Ive tried not casting
> the dictionary keys as strings and I get the same error.  I dont
> understand because when I print the dictionary after reading it from
> the pickled file it is in string form.  I should also say that these
> unicode objects Im reading in are always integer numbers.  So when i
> read in from the database my end result it something like: {'200': 1,
> '300': 4, etc...}.  WHat is going wrong here?

Impossible to say without seeing some code. I would say, though, that
if you're just saving a dictionary of string/integer pairs, you may be
better off with a serialization format like json - which is in the
standard library - rather than pickling.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to