Initializing FLAGS=None
is just a way to initialize a global constant. If left as is, this will lead to an error in main
, since None
does not have any attributes.
But if you install through argparse
parser
, as shown in more complete examples, it is a simple object with many attributes. main
assumes that one of these attributes is called data_dir
.
If after
FLAGS, unparsed = parser.parse_known_args() print(FLAGS)
you should see Namespace(data_dir='a directory', ....)
, where the value for data_dir
was parsed from the command line.
source share