Jump to content

File to Dictionary

- - - - -

  • Please log in to reply
2 replies to this topic

#1
AIGuy

AIGuy

    Learning Programmer

  • Members
  • PipPipPip
  • 64 posts
I've got a file with text completely valid to a python dictionary definition(no pun intended). I could go to the idle and type:
dict1 = 
and then paste in the contents and have a valid dictionary.

Is there an easy way to get this loaded straight in? I could write my own function but, like i said, it's already in the perfect format.

#2
EyeballKid

EyeballKid

    Newbie

  • Members
  • Pip
  • 7 posts
Sounds like execfile might be the kind of thing you're after...

Not sure if you've got control over the format of the original file, but if you do, then I tend to recommend json format for such things these days - especially if it's going to be accessed from other programming languages. Most have pretty good support for reading and writing it.
Looking for a job that doesn't suck? Try not getting hired to make posts with a spam-sig!

#3
AIGuy

AIGuy

    Learning Programmer

  • Members
  • PipPipPip
  • 64 posts
thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users