reflected greater than magic methods
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Jungle Looping
--
Chapters
00:00 Reflected Greater Than Magic Methods
01:10 Answer 1 Score 4
01:21 Answer 2 Score 0
01:32 Accepted Answer Score 3
01:50 Thank you
--
Full question
https://stackoverflow.com/questions/3017...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #magicmethods
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Jungle Looping
--
Chapters
00:00 Reflected Greater Than Magic Methods
01:10 Answer 1 Score 4
01:21 Answer 2 Score 0
01:32 Accepted Answer Score 3
01:50 Thank you
--
Full question
https://stackoverflow.com/questions/3017...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #magicmethods
#avk47
ANSWER 1
Score 4
__lt__ is __gt__'s counterpart; you'll need to implement __lt__. While you're at it, you should probably implement __le__ and __ge__.
ACCEPTED ANSWER
Score 3
You can use a functools.total_ordering decorator to create the missing comparison methods for you:
import functools
@functools.total_ordering
class Property():
...
Then you get False, False, False. Do make sure to read its documentation, though.
ANSWER 3
Score 0
Since you've declared the __float__() method, you could always write it as:
print float(y) > float(x)