the following >>> getopt.getopt('--testing=dr'.split(), '', ['testing'])[0] would raise 'option --testing must not have an argument'. Documentation reads, however: "Long options which require an argument should be followed by an equal sign ('=')." Which is equivalent to "options that don't require an argument, should not be followed by the equal sign". The fact that in my example argument is not required does not mean that argument cannot be passed.
issue is in the wording: "Long options which require an argument should be followed by an equal sign ('=')." What if the argument is optional? Then by definition it is not required, but as my example shows omitting the equal sign, would produce the error. I'd suggest that the docs should read something along these lines: "Long options which accept an argument should be followed by an equal sign ('='). Passing an argument to an option without an equal sign is illegal." Basically, it's not clear that "optional" arguments should be passed like this: >>> getopt.getopt('--testing='.split(), '', ['testing']) Note the difference with my previous example.