将Python argparse.Namespace()视为字典的正确方法是什么?
如果我想将的结果(argparse.ArgumentParser()即Namespace对象)与需要字典或类映射对象的方法一起使用(请参阅collections.Mapping),那么正确的方法是什么? C:\>python Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> import argparse >>> args = argparse.Namespace() >>> args.foo = 1 >>> args.bar = [1,2,3] >>> args.baz = 'yippee' >>> args['baz'] Traceback (most recent …