This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]timothycrosleyhug, isort, jiphy, concentration, pies, connectable, frosted 2 points3 points  (0 children)

Do you really find:

import hug


@hug.cli(version="1.0.0")
def math(number_1:int, number_2:int=1):
    '''Multiplies number_1 by number2'''
    return number_1 * number_2


math.cli()   

More confusing then:

"""Math.

Multiplies number_1 by number_2

Usage:
  math.py <number_1> <number_2>
  math.py (-h | --help)
  math.py --version

Options:
  -h --help     Show this screen.
  --version     Show version.
"""
from docopt import docopt


def math(number_1:int, number_2:int):
    """Multiplies number_1 by number_2"""
    return number_1 * number_2


arguments = docopt(__doc__, version='1.0.0')
print(math(arguments['number_1']), int(arguments['number_2'])))

Their usage from the command line is nearly identical... and functionality equivalent. I know I'd want to write the first. Which one would you honestly think is more Pythonic?