Sib007 / intro_machine_learning_using_python

0 stars 0 forks source link

Using argparse #3

Open Sib007 opened 1 year ago

Sib007 commented 1 year ago

I'm still very unsure about how to use/write argparse, so I was wondering if you could have a look at my attempt to incorporate argparse into my script (which I put in the file script-with-argparse.py for now, to avoid breaking the main file if something goes wrong while messing with argparse) and let me know if I'm on the right track or if I'm doing it wrong?

Many thanks in advance!

montesmariana commented 1 year ago

It is not bad in itself but it's a lot of arguments for a command line function, I feel. If someone wants to use your script in the command line they have to do this:

python script-with-argparse.py "Project title" "Name of the client" English French 40000 "2023-06-07" "2023-10-05" 1200 False

That... looks kind of tough. If you already try run your code on a list of dictionaries from a json file, why don't you only provide the json file as argument and use that instead? Then the user would have to do something like:

python script-with-argparse.py myprojects.json

And you can check whether it's one dictionary (and you print the information of that Project) or a list of dictionaries (and you print the information of all the projects). Or they would have to provide two jsons, one with project information and one with freelancers information, and maybe these are positional arguments or maybe they can have names.

Think of what you would want an user to do... or rather, what a user would want to use your script for.