def write_callback(option, _opt_str, _value, parser, *_args, **_kwargs):
 if (not hasattr(parser.values, 'write')):
  option.dest = 'write'
  option.action = 'store_false'
  parser.values.write = False
  for _ in range(3):
   testphrase = 'Yes, I want to enable write support'
   response = raw_input((('Write support requested.  Please type "' + testphrase) + '" below precisely (case-sensitive):\n'))
   if (response == testphrase):
    option.action = 'store_true'
    parser.values.write = True
    return
  print 'Write support disabled.'

def write_callback ( option , _opt_str , _value , parser , * _args , ** _kwargs ) : if ( not hasattr ( parser . values , 'write' ) ) : option . dest = 'write' option . action = 'store_false' parser . values . write = False for _ in range ( 3 ) : testphrase = 'Yes, I want to enable write support' response = raw_input ( ( ( 'Write support requested.  Please type "' + testphrase ) + '" below precisely (case-sensitive):\n' ) ) if ( response == testphrase ) : option . action = 'store_true' parser . values . write = True return print 'Write support disabled.'
callback function to ensure that write support is only enabled if user repeats a long string this call back checks whether the user really wants write support and then either enables it by changing the option to store_true .