6 ms·
Modern Python is quite close to the ruby version: from dataclasses import dataclass @dataclass(order=True) class AppVersion: major: int =
by BiteCode_dev 11mo ago
Modern Python is quite close to the ruby version:
from dataclasses import dataclass
@dataclass(order=True)
class AppVersion:
major: int = 0
minor: int = 0
patch: int = 0
@classmethod
def from_string(cls, version_string):
parts = map(int, str(version_string).split('.'))
return cls(*parts)
def __str__(self):
return f"{self.major}.{self.minor}.{self.patch}"
All languages steal from each other, so on a long enough time scale, it makes sense they kinda converge.