Hacker News new | past | comments | ask | show | jobs | submit login

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")



Wouldn'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")




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: