Q:

argparse not taking default option

Can anyone tell me why the default option is being taken below?
Code:
import argparse
parser = argparse.ArgumentParser(description='SCRIPT')
parser.add_argument('-fe','--force_edl',action='store',dest='force_edl',choices=['True', 'False'], default = False,help='<Required> Enable EDL loading by default..',required=False)
global force_edl
results = parser.parse_args()

if results.force_edl:
    force_edl = results.force_edl
print "force_edl"
print force_edl

Error message:

Traceback (most recent call last):
File "defaultparse.py", line 10, in 
print force_edl
NameError: global name 'force_edl' is not defined

A:

if results.force_edl:
    force_edl = results.force_edl

The reason why the assignment inside the above if doesn't take place is because:
>>> results
Namespace(force_edl=False)
>>> results.force_edl
False

results.force_edl is a boolean with the value False. What you instead need to be doing is:
if 'force_edl' in results:
    force_edl = results.force_edl

Or, since you already know that results will always have force_dl, just assign directly:
force_edl = results.force_edl

