[Q/newbie] Converting object names to strings and back?
Adam Twardoch
list.adam at twardoch.com
Tue Aug 21 01:19:15 EDT 2001
----- Original Message -----
From: "Richard Jones" <richard at bizarsoftware.com.au>
> Note that unless you're doing this for reasons of radability or
editability,
> Python already has facilities for dumping and reading objects to and from
> files. Look up pickle and marshal in the standard library reference.
Yes, I've seen pickle & marshall. But I need to make the data I'm writing to
fit particular formatting, and to make it editable. After all, at some point
I will probably want to submit the data to a ODBC database via COM, rather
than writing to a file.
> ... but eval should be considered dangerous (as should $$variable I think)
if
> the source of the string is not "trusted". The first solution is far
safer,
> using explicit introspection techniques.
Thank you Richard! I'll write a function which uses eval for the beginning,
because the code I'm writing is just for internal purposes. At some point,
I'll rewrite the function to use a safer method, like the one you described!
Adam
More information about the Python-list
mailing list