getting class based on attribute?

How do I get a class based on its attribute? For example, I have a class for each person, I then sort them by self.speed which is a attribute of the class and then rearrange them in the list by their self.name which is another attribute of the class, is it possible for me to replace the self.name string with the actual class object itself?

I did try to sort the list by just using the class object itself but if would give me <… object> <… object> stuff instead. So I did this but yea it just gives me the string back when I want to do more with the class itself

    team = [         p.name         for p in sorted(team,                         key=lambda x: x.full_speed,                         reverse=True)     ]      
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.