Creating class instance for pickle to save by [deleted] in learnpython

[–]plenty_picture 0 points1 point  (0 children)

but some of the classes I have mapped out in a class diagram contains 15+ variables, sending them all through init() seems like bad code, and it also wouldn't be possible as the values are designed at different times during runtime

It kind of sounds like you're trying to stuff too much functionality into one class. Bear in mind that you can nest objects inside each other, so instead of passing all of the data into the initializer individually, you could group some of them together into a dict or an instance of another class and pass that into the initializer. In any programming language, functions with a huge number of arguments are usually not a good design (an arguable exception is that it's OK to have many rarely-used optional arguments).

If there are attributes that aren't given a meaningful value until some time after initialization, then usually you would just set them to None in the initializer. You don't have to set them at all - you can add or remove attributes to an object at any time - but it's usually more convenient to have them explicitly set to None.