Open falkamelung opened 4 months ago
Falk: Useful code snippets from Kawan's run_plot_precipitation_all.py :
https://github.com/geodesymiami/Precip_cron/blob/9ca7d19f937e7dce45b548a8cd61ebe832690fe3/run_plot_precipitation_all.py#L13-L16
https://github.com/geodesymiami/Precip_cron/blob/9ca7d19f937e7dce45b548a8cd61ebe832690fe3/run_plot_precipitation_all.py#L44-L47
https://github.com/geodesymiami/Precip_cron/blob/9ca7d19f937e7dce45b548a8cd61ebe832690fe3/run_plot_precipitation_all.py#L88
Kawan: Regarding the last point, there are two ways to initialize an argparse.Namespace.
The way I did it in run_plot_precip… is:
inps = argparse.Namespace(style=style, name=[volcano], no_show=True) import argparse kwargs = {'key':'value', 'hello':'world', 'im_not': 'paid_enough’}
inps = argparse.Namespace(style=style, name=[volcano], no_show=True)
import argparse kwargs = {'key':'value', 'hello':'world', 'im_not': 'paid_enough’}
argparse.Namespace(** kwargs) Namespace(key='value', hello='world', im_not='paid_enough’)
argparse.Namespace(key='value', hello='world', im_not='paid_enough') Namespace(key='value', hello='world', im_not='paid_enough’)
But result is the same object. But passing **kwargs is great when you have a lot of key word arguments or want to pass things dynamically.
This is also the case for (or any other object with a similar init method).
https://github.com/python/cpython/blob/e8c91d90ba8fab410a27fad4f709cc73f6ffcbf4/Lib/argparse.py#L1295-L1297
Falk: Useful code snippets from Kawan's run_plot_precipitation_all.py :
https://github.com/geodesymiami/Precip_cron/blob/9ca7d19f937e7dce45b548a8cd61ebe832690fe3/run_plot_precipitation_all.py#L13-L16
https://github.com/geodesymiami/Precip_cron/blob/9ca7d19f937e7dce45b548a8cd61ebe832690fe3/run_plot_precipitation_all.py#L44-L47
https://github.com/geodesymiami/Precip_cron/blob/9ca7d19f937e7dce45b548a8cd61ebe832690fe3/run_plot_precipitation_all.py#L88
Kawan: Regarding the last point, there are two ways to initialize an argparse.Namespace.
The way I did it in run_plot_precip… is:
option 1
option 2
But result is the same object. But passing **kwargs is great when you have a lot of key word arguments or want to pass things dynamically.
This is also the case for (or any other object with a similar init method).
https://github.com/python/cpython/blob/e8c91d90ba8fab410a27fad4f709cc73f6ffcbf4/Lib/argparse.py#L1295-L1297