carpentries-lab / python-aos-lesson

Python for Atmosphere and Ocean Scientists
https://carpentries-lab.github.io/python-aos-lesson/
Other
87 stars 49 forks source link

Argparse #46

Closed pletzer closed 1 month ago

pletzer commented 2 years ago

Hi @DamienIrving

This PR replaces argparse by the defopt module. Defopt automates a lot in terms of creating command line arguments. All the user needs to do is to document the code and define interfaces, which is good practice anyway. It's also easier to have default arguments.

I kept the argparse module in some files, we're not completely replacing argparse with defopt, just encouraging the use of defopt.

DamienIrving commented 2 years ago

Thanks, @pletzer. I wasn't aware of defopt - it looks great.

I think you should definitely go ahead and use defopt for your workshop at ICSHMO (i.e. directing participants to your forked lesson materials at https://pletzer.github.io/python-aos-lesson). I'll need to have a bit of think about whether to switch to defopt for the official PyAOS Data Carpentry lessons. The rationale for using argparse was that unless there's a very widely used alternative, I like to stick with the python standard library. I don't get the sense defopt has separated itself as the clear winner from all the other command line parsers out there, but I could be wrong?

At the very least, one thing I could do is add an information box to the command line programs lesson to tell people that defopt is a good alternative. That's what I've done in the package management lesson with mamba. It's much better than conda but hasn't overtaken it in terms of popularity/usage, so the lesson uses conda but mentions mamba in an information box.

DamienIrving commented 1 month ago

Closing this pull request as I can't have any open PRs when commencing the transition to the Carpentries Workbench.