As in Python everythong is an object you could use __name__.
>>> import cPickle
>>> def def1():
...pass
>>> def def2():
...pass
>>> def1.__name__
def1
>>> def2.__name__
def2
in this case you can combine __name__ to get the object name and then
combine it with eval to pickle.
>>> pickleSt
On Apr 3, 3:48 pm, Aaron Scott wrote:
> > Why not use import ? Simply recreate the source file, if necessary, and
> > import it again.
>
> Ah, you'd think it would be that easy :P
>
> The problem with just importing a module is that the module is then
> cached in memory. Multiple copies of the pr
> Why not use import ? Simply recreate the source file, if necessary, and
> import it again.
>
Ah, you'd think it would be that easy :P
The problem with just importing a module is that the module is then
cached in memory. Multiple copies of the program are running on a
server, and each of them h
Aaron Scott wrote:
Pickling the source code is much sturdier. It's very unlikely that
the same code runs differently in different interpreters. It's much
more likely that the same code runs the same, or not at all.
Okay, I've run into another problem. I've saved the code to a string,
so
Never mind. Solved the problem by putting the functions in a class and
dumping that into a string. Then, when I need it, I executed the
string to get myself the class, then created an instance of that class
which gave me access to those functions along with the correct scope.
Probably not the smart
> Pickling the source code is much sturdier. It's very unlikely that
> the same code runs differently in different interpreters. It's much
> more likely that the same code runs the same, or not at all.
Okay, I've run into another problem. I've saved the code to a string,
so I can call it up when
On Apr 3, 11:04 am, Aaron Scott wrote:
> I have a number of functions that I need to pickle without necessarily
> knowing their names in advance. My first thought was to put all the
> functions in a class, then pickle the class, but it doesn't really
> work like I expected it to.
>
> impor