setter methods in various code
zopyx opened this issue · 2 comments
Looking at examples/create_forest.py
The tons of set_xxx() methods are completely superfluous and unpythonic.
Why don't you just use
create.some_property = value
directly instead of usinger setter methods? Python is not Java!
Interesting. Are they really a python antipattern?
If one wants to have validation when necessary and consistency, it seemed like they were necessary.
setter/getter methods are the anti-pattern #1. No offense but this anti-pattern is often seen by code written by people from the Java world. We call that "unpythonic".
Regarding validation: I would pass the result from parse_args() to a dedicated validation method performing the validation of all parameters. Or you look into a higher-level module 'click'
http://click.pocoo.org/5/ for having parameter types or hooks for validation. 'click' is not part of the Python core but you are already using external dependencies like 'requests'...so further deps should not be a big problem.