Which of these two class implementations is more pythonic / conventional?
I have two almost identical versions of a class that is used to interact with the zoho sheets api.
It essentially works by allowing you to call zs.context.action or zs.action.context – both are equivalent.
in zs.foo.bar, zs.foo returns an instance of the foo class and bar is a method of foo
Should the call to foo be a method like zs or an attribute like zs2?
zs – using methods:
zs.select(
workbook_id="3o8ua1fa990f83cfoobarbaz",
worksheet_name="Sheet1"
)
zs.list_all().templates()
zs.template().list_all()
zs.cell().get(1,1)
zs.get().cell(1,1)
zs2 – using attributes:
zs2.select(
workbook_id="3o8ua1fa990f83cfoobarbaz",
worksheet_name="Sheet1"
)
zs2.list_all.templates()
zs2.template.list_all()
zs2.cell.get(1,1)
zs2.get.cell(1,1)
mouldy-ketchup is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
The most Pythonic way, in my opinion, would be
zs.list_all_templates()
zs.get_cell(1,1)
Without intermediate grouping, and more readable.
makukha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.