method names nounVerb or verbNoun
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Feb 5 17:31:32 EST 2010
On Fri, 05 Feb 2010 11:53:08 -0800, Wanderer wrote:
> Which is the more accepted way to compose method names nounVerb or
> verbNoun?
>
> For example voltageGet or getVoltage? getVoltage sounds more normal,
+0.5 for getVoltage
+1 get_voltage
-1 for voltageGet or voltage_get
> but
> voltageGet is more like voltage.Get.
According to PEP 8, the style guide for the standard library, method
names should use lowercase initial letter, so you should have
voltage.get. Following PEP 8 isn't compulsory, but it is recommended
unless you want a bunch of busy-body coders telling you you need to
follow PEP 8 :)
> I seem to mix them and I should
> probably pick one way and stick with it.
Yes.
--
Steven
More information about the Python-list
mailing list