(Aug-25-2019, 03:04 AM)Skaperen Wrote: now i really need to understand decorators and what they do.Not really,there is no problem teaching someone Click that don't know what a decorator is.
It's make the interface a lot cleaner eg using
@click.command()
than have all code make it up in the interface.It' really the same for most libraries with or without decorator
requests.get('https://python-forum.io/')
.I do not all need to see the eg 50 lines of code of
requests.get()
to use it.A decorator is easy in it's core.
def make_bold(fn): '''Do not need to see me''' def new_func(): return f"<b>{fn()}</b>" return new_funcUser only need to add
@make_bold
,the name give a hint what it dos or make documentation for it.@make_bold def foo(): return 'python-forum' print(foo())
Output:<b>python-forum</b>