4 ms·
This was what one of our Java coworkers wrote a while back: https://gist.github.com/1337/8155054 https://gist.github.com/1337/8155054
by solox3 13y ago
This was what one of our Java coworkers wrote a while back: https://gist.github.com/1337/8155054 https://gist.github.com/1337/8155054
- gagege 13y agoThat kind of code could make sense when you're using a very opinionated API, that is designed (for better or worse) with patterns in mind, such as Android. But, when you start bringing that style of coding outside of that environment... Yuck.
- elwell 13y agoI don't think you need to even explicity say he's used to Java. Wow... I've never felt the need to the use the factory technique.
- marcosdumay 13y agoI use factories a lot when using Django... But, of course, in Python they are functions that return a class, not classes. Interfaces instead are completely unpythonic. Or, maybe I should call them antipythonic?
- epidemian 13y agoAt least they followed the snake_case name convention for method names (albeit getters) ;)
- anon4 13y agoIt won't work on py3 because map is a generator. Tell him to use list comprehensions: [setattr(self, x, kwargs[x]) for x in kwargs.keys()] Though of course that is a bit too slow and he should do self.__dict__.update(**kwargs) or for maximum correctness import os; os.remove(__file__)