Making every no-arg method a property?
Chris Angelico
rosuav at gmail.com
Tue Aug 5 22:07:58 EDT 2014
On Wed, Aug 6, 2014 at 10:49 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> A
> plethora of argument-less methods is a code smell -- that doesn't mean it's
> *necessarily* a bad idea, but the class design really needs a careful
> review.
There are plenty of no-argument mutator methods, where the name of the
method (and the target object, obviously) is all the info you need.
You can clear() or copy() something with any more info, reverse() a
list, pop() from a list, etc. (Okay, the last one has a default
argument, but that raises an even worse point: adding a defaulted
argument to a no-argument method suddenly stops it from being a
property, which violates the usual rule that you can add a defaulted
argument to anything without breaking anything.)
ChrisA
More information about the Python-list
mailing list