Live data from Hacker News

Click – Python library for command-line interfaces

click.pocoo.org

1–10 of 105 posts

Re: Click – Python library for command-line interfaces

#3
Gorgeous. This guy has a full time job, a wife, and wrote Flask and Werkzeug, ItsDangerous, Sphinx, Markupsafe, Jinja2 (and Jinja) and that's just some of the well known stuff. Handsome and young too. Bastard. He probably saves the world in a dinner jacket in his spare time.

Re: Click – Python library for command-line interfaces

#5
Kudos again to the pocoo team for creating such a simple and useful library. It sure beats optparse :)

On a side note, however, does anyone know why the team prefers to wrap functions in decorators? Flask also uses them, but what's the design decision behind them?

Re: Click – Python library for command-line interfaces

#6

Kudos again to the pocoo team for creating such a simple and useful library. It sure beats optparse :) On a side note, however, does anyone know why the team prefers to wrap functions in decorators? Flask also uses them, but what's the design decision behind them?

Decorators are so simple and minimalistic and elegant and easy to understand. They can surface an arbitrary amount of extra functionality with a single statement. For example, ensure a function is only accessible to authenticated users by simply saying something like @requires_authenticated_user. Another example would be to create a logging decorator to wrap a function or a class to create a log of every time the function is accessed @log_function_access. Or to wrap a function to ensure that every access to the properties of that function are pushed through some sort of validation or transformation @validate_set or @transform_get. Decorators allow encapsulation of functions within other functional concepts with almost no code, that's the design decision for using them.
Post reply on HN