Reasoning of calling a method on class object instead of class instance object
On 03/18/2019 05:55 PM, Ben Finney wrote:
>> If I call `_c_to_f`, `_f_to_c` methods on `self` instead of
>> `RefrigeratedShippingContainer` class object, still it works.
> That's right, and is indeed the point of making a static method on a
I'm confused. The methods that refer to
RefigeratedShippingContainer.MAX_CELSIUS are not static methods. For
example, __init__() and celsius(). In fact he never said anything about
static methods unless I'm really missing something.
> In the specific example you show, I expect the code maintenance was
> deemed to be easier when the RefrigeratedShippingContainer encapsulates
> the conversions of temperature units.
I'm not sure this answers his question. He's asking why refer to a
class variable with the class's name when self also apparently works.