Re: Save and load initialized class

2017-12-10 Thread Bob van der Poel
Yes, all cool. But, json.dump(Opts.__dict__, open("mybuffer", "w")) still doesn't work with python3. Returns "is not JSON serializable" On Sun, Dec 10, 2017 at 4:00 AM, Steve D'Aprano wrote: > On Sun, 10 Dec 2017 04:52 am, MRAB wrote: > > > Try updating __dict__: > > > > Opts.__dict__.

Re: Save and load initialized class

2017-12-10 Thread Steve D'Aprano
On Sun, 10 Dec 2017 04:52 am, MRAB wrote: > Try updating __dict__: > > Opts.__dict__.update(json.load(open("mybuffer"))) __dict__ is implementation, vars() is the public interface: vars(Opts).update(json.load(open("mybuffer"))) Looks nicer too :-) -- Steve “Cheer up,” they said, “th

Re: Save and load initialized class

2017-12-09 Thread MRAB
On 2017-12-08 18:36, Bob van der Poel wrote: I'm trying to something simple (yeah, right). Mainly I want to have a bunch of variables which my program needs and uses to be in a saveable/loadable block. Currently I have then all as a bunch of globals which works, but trying to keep track of them a

Re: Save and load initialized class

2017-12-09 Thread dieter
Bob van der Poel writes: > I'm trying to something simple (yeah, right). Mainly I want to have a bunch > of variables which my program needs and uses to be in a saveable/loadable > block. Currently I have then all as a bunch of globals which works, but > trying to keep track of them and the corre

Save and load initialized class

2017-12-08 Thread Bob van der Poel
I'm trying to something simple (yeah, right). Mainly I want to have a bunch of variables which my program needs and uses to be in a saveable/loadable block. Currently I have then all as a bunch of globals which works, but trying to keep track of them and the correct spellings, etc becomes a bit of