this post was submitted on 23 Aug 2023
6 points (100.0% liked)

Python Dev

1 readers
1 users here now

founded 1 year ago
MODERATORS
top 4 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 1 year ago

Click is awesome, I use it all the time for small and medium sized python projects!

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

Hmm, I wonder how it compares to Traitlets? I got recommended that and it's taken me a while to learn, but it is very powerful. I'm just starting on a subcommand based app, so this is very relevant to me!

EDIT: Just glancing at the documentation I can see the docs are way better!

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

Traitlets

Click is a library to make a CLI - e.g.

"""echo.py"""

@click.command()
@click.arg("foo")
def echo(foo):
  print(foo)

if __main__: 
  echo()
python ./echo.py "Hello World"

vs Traitlets looks like a (really cool) type validation library? Pydantic is similar

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

Traitlets also supports subcommands, command line arguments, etc. At its heart though, it's more of a configuration library.

(I'm very much still a novice coder so definitely take that into account lol!)

https://traitlets.readthedocs.io/en/stable/config.html#command-line-arguments