-v --log test log.txt
When I run test.py I get the message
UNKNOWN. Unknown option: --log.
A:
To use argument parsing, you need to have a main method in a class (or module), you can't do it with a script directly. In your case, just change:
if __name__ == "__main__":
test_main()
To:
def main():
And you should be fine. The return value of the function is used by argparse as the name of the next argument to pass to the parser function, i.e.
parser(argparse.ArgumentParser(add_help=False))
Now parses the following arguments:
$ test.py --log --help
Usage: test.py [options]
...
If you want to keep the main function, you should probably use try except KeyboardInterrupt to catch the interrupt:
try:
test_main()
except KeyboardInterrupt:
print "User pressed Ctrl+C"
Q:
php - access dynamically created button elements
I am working on a booking system which displays the booking details with a table. There is a column where the user can check the payment status of a booking. I have created a button on the table that has a value (chk_status) which is dynamically created based on the contents of a table.
I would like the following code to run:
if ($_GET['chk_status'] == "On") {
$bool = "checked";
} else {
$bool = "unchecked";
}
and then I would like to get the value of $bool and apply it to the checkbox.
My problem is that I have no idea how to get the value of this button.
I have tried:
echo '
function ChangeCheckbox() {
if ($_GET['chk_status'] == "On") {
Related links: