Created
August 10, 2017 14:03
-
-
Save dastergon/67f1cbfbdc48c6d8c52e3fcebdf4bdff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: class One: | |
...: def __init__(self): | |
...: self.bw_rate = 1 | |
...: | |
In [2]: class Two: | |
...: def __init__(self): | |
...: self.bw_rate = 0 | |
...: | |
In [3]: from operator import attrgetter | |
In [4]: max(One(), Two(), key=attrgetter('bw_rate')) | |
Out[4]: <__main__.One at 0x103f01978> | |
In [5]: max(One(), Two(), key=attrgetter('bw_rate')).__dict__ | |
Out[5]: {'bw_rate': 1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment