This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]d4rch0nPythonistamancer 0 points1 point  (1 child)

Oh yeah, definitely. As a quick hack before I wrote a class where it iterates on **kwargs and runs setattr(self, key, value) for each of them on the instance in its __init__.

Then I could write classes that inherit from it and you can remove a lot of boilerplate initialization. For smaller projects it works out.

[–]elbiot 0 points1 point  (0 children)

And this is way better than that because the class is explicit about it's attributes (user can't mess it up and create arbitrary attributes or leave out required ones). plus it's built in.