2 ms·
Well, there's nothing wrong with providing a shortcut, although personally I would have preferred a closure: printred = colored.print_function("red") p
by icebraining 15y ago
Well, there's nothing wrong with providing a shortcut, although personally I would have preferred a closure:
printred = colored.print_function("red")
printred("This prints in red")
- j_baker 15y agoWouldn't this work? I can't test it at the moment. print_function = lambda c: getattr(colored, c) printred = colored.print_function("red") printred("This prints in red")