I'm trying to programmatically define several variables in the local namespace:
for build_step in 'prepare', 'configure', 'make', 'stage', 'package', 'all':
p = build_subparsers.add_parser(build_step)
p.set_defaults(build_step=build_step)
if build_step != 'package':
p.add_argument('specfile')
locals()['build_'+build_step+'_parser'] = p
build_prepare_parser
NameError: global name 'build_prepare_parser' is not defined
However after running this code, none of the variables I presumed to create actually exist despite appearing in locals(). How do I do this in Python 3.2?
Update0
I know locals() is a bad idea, that's why I'm asking this question.