by nickelbox · 8y ago · 0 comments
sorted( (k.weight, k.name).for_(k).in(somelist), reverse=true));
You would never be able to get that past code review, however.
The other thing to note is that
sorted([(k.weight, k.name) for k in somelist], reverse=True)
is essentially already typechecked: def biggest_ks(ks: K):
return sorted([(k.weight, k.name) for k in ks], reverse=True)
The above code now has all the same type guarantees as your c++, actually maybe more since the macros you use are going to be...uhhh, mysterious.My point was just that you can implement almost whatever you want (even without macros, they'll just expand the design space).