Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You're never forced to use decorators, they're just syntactic sugar.

Their example:

  @click.command()
  @click.option('--count', default=1, help='number of greetings')
  @click.option('--name', prompt='Your name',
              help='the person to greet', required=True)
  def hello(count, name):
      for x in range(count):
          print('Hello %s!' % name)
Could be written as:

  def hello(count, name):
      for x in range(count):
          print('Hello %s!' % name

  hello = click.option('--name', prompt='Your name', 
             help='the person to greet', required=True)(hello)
  hello = click.option('--count', default=1, help='number of greetings')(hello)
  hello = click.command(hello)


The command decorator is nice, but the group decorator feels wrong, why create a function that does nothing just to decorate it? I'd rather use `cli = click.Group()`.




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

Search: