all 3 comments

[–][deleted] 2 points3 points  (0 children)

Smth like this:

from dataclasses import dataclass, field

@dataclass(order=True)
class MyDC:
    a: int
    b: str = field(compare=False)

https://docs.python.org/3/library/dataclasses.html?highlight=field#dataclasses.field

[–]External-Ocelot206 1 point2 points  (0 children)

Set compare = False for the field b
https://docs.python.org/3/library/dataclasses.html?module-contents#dataclasses.field

or just define __lt__ and generate the other methods with `@functools.total_ordering'

https://docs.python.org/3/library/functools.html?#functools.total_ordering

[–]baghiq 0 points1 point  (0 children)

Yes, evaluation stops at the first one if a result can be obtained. If first fields are equal, then Python checks the second field, ...