On Tue, Jul 7, 2009 at 4:27 PM, Iustin Pop<[email protected]> wrote: >> - if options.no_voting: >> + if options.no_voting and not options.yes_do_it: >> sys.stdout.write("The 'no voting' option has been selected.\n") >> sys.stdout.write("This is dangerous, please confirm by" >> " typing uppercase 'yes': ") >> @@ -481,7 +485,7 @@ def main(): >> if confirmation != "YES": >> print "Aborting." >> return >> - else: >> + elif not options.no_voting: >> if not CheckAgreement(): >> return > > I can't see the whole if here, but are you sure this if branch is > correct? I would have expected more: >
This is the whole if, and it works as expected: First branch is taken when no_voting is set, and we have to require confirmation. It requires confirmation, and then the second branch doing the vote is skipped. The second branch is taken when no_voting is not set, and the elif is there, as opposed to the else, because if no_voting is set and yes_do_it is set as well, then the first branch (for the confirmation) will be skipped, and the second one, for the voting, will be skipped as well. > if options.no_voting: > if not options.yes_do_it: > ask for confirmation > else: > if not check agreement(): return > The code there is basically equivalent to this. Thanks, Guido
