Closed zerothi closed 11 months ago
There was no particular reason that I used staticmethods over classmethods as they both work. Are there any advantages for using classmethods over staticmethods in this case?
The advantage is that when you subclass it will return based on the class:
@classmethod
def from_reactance_at_frequency(cls, reactance: float,
frequency: float, index: int | None = None) -> Capacitor:
value = -1 / (2 * math.pi * frequency * reactance)
return cls(value, index)
Otherwise the advantage is just the clarity of the method, but that is perhaps a preference thing.
https://github.com/dtudk/lc-power-match-baluns/blob/0fdf0f8963e6a960c4c8f0fb3e3a7401ad990052/src/lc_power_match_baluns/oneport.py#L119
Just a suggestion, why not a classmethod?