self=pickle.load(file)? (Object loads itself)
Simon Forman
rogue_pedro at yahoo.com
Sat Aug 12 13:59:32 EDT 2006
Anton81 wrote:
> Hi!
>
> it seems that
>
> class Obj:
> def __init__(self):
> f=file("obj.dat")
> self=pickle.load(f)
> ...
>
> doesn't work. Can an object load itself with pickle from a file somehow?
> What's an easy solution?
>
> Anton
Why are you trying to do this? Usually you would just say obj =
pickle.load(f) and be done with it (you could manipulate obj after it's
created, of course.) Why do you want to do obj = Obj() but have the
obj come from "obj.dat"?
Just curious.
Peace,
~Simon
More information about the Python-list
mailing list