How to pass on argparse argument to function as kwargs?

后端 未结 1 341
你的背包
你的背包 2021-01-01 09:22

I have a class defined as follows

class M(object):
    def __init__(self, **kwargs):
        ...do_something

and I have the result of

相关标签:
1条回答
  • 2021-01-01 10:01

    You need to pass in the result of vars(args) instead:

    M(**vars(args))
    

    The vars() function returns the namespace of the Namespace instance (its __dict__ attribute) as a dictionary.

    Inside M.__init__(), simply ignore the message_type key.

    0 讨论(0)
提交回复
热议问题