Skip to content

Instantly share code, notes, and snippets.

@dastergon
Created August 10, 2017 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dastergon/67f1cbfbdc48c6d8c52e3fcebdf4bdff to your computer and use it in GitHub Desktop.
Save dastergon/67f1cbfbdc48c6d8c52e3fcebdf4bdff to your computer and use it in GitHub Desktop.
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