I have just tried to lint some code with Pylint, and the last remaining error is
R0902: too-many-instance-attributes (8/7)
I understand the rationale behind limiting the number of instance attributes, but seven seems a bit low. I also realise that the linter should not have the last word. However, I would like to know what I should be doing instead of:
def __init__(self, output_file=None, output_dir=None):
"""
Set the frobnicator up, along with default geometries
"""
self.margin = 30
self.pos = [0, 0]
self.sep = [5, 5]
self.cell = [20, 20]
self.frobbr = library.Frobbr()
page = self.frobbr.get_settings('page')
self.lim = [page.get_width() - self.margin,
page.get_height() - self.margin]
self.filename = output_file
self.moddir = output_dir
Should I package the geometries up into a dict, do something else to stop Pylint complaining, or just ignore it (which I don't really want to do)?
self.moddir
andself.filename
into an attribute namedself.output_path
. It could either be a string such asos.path.join(self.moddir, self.filename)
or a tuple of(self.moddir, self.filename)
. – Gaylord