Whether we can add a default argument for FLAGS?
llan-ml opened this issue · comments
In my case, I only use absl.flags
to parse command line parameters. So, I have to manually pass sys.argv
to FLAGS
. Can we set a default argument when calling FLAGS
? Or, does a default value have some drawbacks?
# Now:
import sys
from absl import flags
FLAGS = flags.FLAGS
FLAGS(sys.argv)
# If we can:
from absl import flags
FLAGS = flags.FLAGS
FLAGS()
The reason why I want this feature is that I'm used to parsing with argparse
as follows:
import argparse
parser = argparse.ArgumentParser()
parser.parse_args()
We used to have FLAGS()
mean parsing nothing, that has been fixed since there were many misuses of the call.
After that, I don't see a technical reason why it can't use sys.argv
as the default if omitted.
However, I'd still prefer explicitness as passing sys.argv
is more clear to the reader, especially people who's less familiar with absl.flags
(prefer optimizing readability over writability too).
Thanks for your response.