Save and load initialized class
Steve D'Aprano
steve+python at pearwood.info
Sun Dec 10 06:00:27 EST 2017
More information about the Python-list mailing list
Sun Dec 10 06:00:27 EST 2017
- Previous message (by thread): Save and load initialized class
- Next message (by thread): Save and load initialized class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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, “things could be worse.” So I cheered up, and sure
enough, things got worse.
- Previous message (by thread): Save and load initialized class
- Next message (by thread): Save and load initialized class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list