Re: reading raw variables from file
- From: Paddy <paddy3118@xxxxxxxxxxxxxx>
- Date: Thu, 29 Nov 2007 22:01:21 -0800 (PST)
On Nov 30, 4:57 am, Astan Chee <st...@xxxxxxxxx> wrote:
Hi,
I have a file that might contain literal python variable statements at
every line. For example the file info.dat looks like this:
users = ["Bob", "Jane"]
status = {1:"ok",2:users[0]}
the problem is I want to read this file and load whatever variables
written in it as normal python variable statements so that when i read
the file, my users var will be ["Bob","Jane"] and my status var will be
{1:"ok",2:users[0]} . Is there an easy way of doing this instead of
parsing the files and checking said types?
Thanks
Cheers
Astan
Think SECURITY. If is someone likely to put malicious code in the file
to crap all over your machine?
If not then import the file as a module.
- Paddy.
.
- References:
- reading raw variables from file
- From: Astan Chee
- reading raw variables from file
- Prev by Date: ImportError: No module named sax.handler?
- Next by Date: Re: python vs pythonw
- Previous by thread: reading raw variables from file
- Next by thread: Re: reading raw variables from file
- Index(es):