Information about a command-line flag.
tf.compat.v1.flags.Flag(
parser,
serializer,
name,
default,
help_string,
short_name=None,
boolean=False,
allow_override=False,
allow_override_cpp=False,
allow_hide_cpp=False,
allow_overwrite=True,
allow_using_method_names=False
)
The only public method of a Flag
object is :meth:parse
, but it is
typically only called by a :class:~absl.flags.FlagValues
object. The
:meth:parse
method is a thin wrapper around the
:meth:ArgumentParser.parse()<absl.flags.ArgumentParser.parse>
method. The
parsed value is saved in .value
, and the .present
attribute is
updated. If this flag was already present, an Error is raised.
:meth:parse
is also called during __init__
to parse the default value
and initialize the .value
attribute. This enables other python modules to
safely use flags even if the __main__
module neglects to parse the
command line arguments. The .present
attribute is cleared after
__init__
parsing. If the default value is set to None
, then the
__init__
parsing step is skipped and the .value
attribute is
initialized to None.
Methods
flag_type
flag_type()
Returns a str that describes the type of the flag.
parse
parse(
argument
)
Parses string and sets flag value.
Args | |
---|---|
argument
|
str or the correct flag value type, argument to be parsed. |
serialize
serialize()
Serializes the flag.
unparse
unparse()
__bool__
__bool__()
__eq__
__eq__(
other
)
Return self==value.
__ge__
__ge__(
other, NotImplemented=NotImplemented
)
Return a >= b. Computed by @total_ordering from (not a < b).
__gt__
__gt__(
other, NotImplemented=NotImplemented
)
Return a > b. Computed by @total_ordering from (not a < b) and (a != b).
__le__
__le__(
other, NotImplemented=NotImplemented
)
Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
__lt__
__lt__(
other
)
Return self<value.