|
|
|
|
|
by d23
4487 days ago
|
|
That line and this one lead me to believe he's full of hot air: > if a method does not use the object's state (no `self` usage) make it a `class-` or `staticmethod`. Uh, that's a little too "cookbook" for my tastes. The decision of whether to make something a class / static method or not should be decided based on what the function is doing, rather than some pointless dogma. I'm assuming he means this method: > def alarm(self):
> with open(BUZZER_MP3_FILE) as f:
> play_sound(f.read()) It's a design decision, and one that is particularly trivial at that. Let's say the effects an alarm ultimately change, resulting in an internal state read / write on the object. Now you have to go back and update the class despite the fact that it at a higher philosophical level one could argue that an alarm should only be triggered on an individual boiler. Point being: it's nit-pickery for nit-pickery's sake. I don't personally use `return None`, but it's certainly more explicit and is fine to use if your judgment has found it to make sense. |
|