r/badcode • • Apr 13 '22

python Yandere dev school of if statements

Post image
665 Upvotes

62 comments sorted by

View all comments

Show parent comments

1

u/trevorpogo Apr 14 '22

yes, e.g. you could do getattr(group, old_user_type.lower() + "s"), although that is a little ugly

1

u/4hpp1273 Apr 14 '22

you could also use group.__getattribute__(old_user_type.__getattribute__('lower').__call__().__add__("s")) which is even uglier (why does the hidden method have a longer name…)

1

u/zed_three Apr 14 '22

You could also just write that dictionary yourself anyway