>
>
> Most objects can be saved with pickle module. The module serializes
> objects to strings by storing *the names* of classes of objects and real
> data (usually, their __dict__ dictionaries.) On restoring (unpickling) the
> loader instantiates objects (it know their class names, right?) and put
> the
> data back.
> But code objects are very special objects in Python. Pickle doesn't save
> it, and you too - you better not meddle with them.
>
> Thanks, I think I will go the "getattr" way.

On Sun, Feb 24, 2008 at 12:11:34AM +0100, Petr Jake?? wrote:
> I see I have to study something new.
Most objects can be saved with pickle module. The module serializes
objects to strings by storing *the names* of classes of objects and real
data (usually, their __dict__ dictionaries.) On restoring (unpickling) the
loader instantiates objects (it know their class names, right?) and put the
data back.
But code objects are very special objects in Python. Pickle doesn't save
it, and you too - you better not meddle with them.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd@...
Programmers don't die, they just GOSUB without RETURN.

>
>
> Oops. It is not possible to store functions (not their names) because
> you have to extract and store Python code objects. Well, it is possible,
> but it is hard and I advise you not to do this. For the function names
> store their names - yes, strings - and then get the function from the
> module by name using getattr.
>
I see I have to study something new. But the night is long ;-)
Thanks to showing me the way.
Petr

On Sat, Feb 23, 2008 at 11:41:38PM +0100, Petr Jake?? wrote:
> I know this question is probably silly, but anyway...
It is not. ;)
> is it possible to store Python objects
Yes, using PicklCol.
> (function names for example) to the
> database?
> Please understand I do not mean a string containing the name of the
> function.
>
> I would like to store function name to the database and read them and
> execute them later on in a function call (call/invoke/execute the function
> putting the parentheses after the function name)
Oops. It is not possible to store functions (not their names) because
you have to extract and store Python code objects. Well, it is possible,
but it is hard and I advise you not to do this. For the function names
store their names - yes, strings - and then get the function from the
module by name using getattr.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd@...
Programmers don't die, they just GOSUB without RETURN.

Hi,
I know this question is probably silly, but anyway...
is it possible to store Python objects (function names for example) to the
database?
Please understand I do not mean a string containing the name of the
function.
I would like to store function name to the database and read them and
execute them later on in a function call (call/invoke/execute the function
putting the parentheses after the function name)
Petr Jakes