r/shittyprogramming • u/CVh655FDBcZ1l • Apr 10 '19
One Line of Code™
https://gist.github.com/WorryingWonton/ce8a3a74b0298f0b734fe4dd0a883a63
101
Upvotes
r/shittyprogramming • u/CVh655FDBcZ1l • Apr 10 '19
View all comments
Show parent comment
14
u/CVh655FDBcZ1l Apr 10 '19
My worst offender in an actual project is this:
def list_cards_of_other_players(self): return [Option(option_name=f'Buy {card.name} from {card.find_owner(game=self.game).name}', item_name=card.name, action=card.start_direct_buy_process, category='buycardfromplayer') for card in reduce(lambda card, next_card: card + next_card, [player.hand for player in list(filter(lambda player: player != self.game.active_player and len(player.hand) > 0, self.game.players))], [])]
I wrote it a few months ago, and now I'm not sure how it works or more importantly what it does.
With the Oneliner-izer, I will no doubt quickly surpass this personal high watermark of unintelligibility and unmaintainability.