title: python3 dataclass with **kwargs(asterisk)
body: <p>Currently I used DTO(Data Transfer Object) like this.</p>
  
  <pre><code>class Test1:
      def __init__(self, 
          user_id: int = None,
          body: str = None):
          self.user_id = user_id
          self.body = body
  </code></pre>
  
  <p>Example code is very small, But when object scale growing up, I have to define every variable.</p>
  
  <p>While digging into it, found that python 3.7 supported <code>dataclass</code></p>
  
  <p>Below code is DTO used dataclass.</p>
  
  <pre><code>from dataclasses import dataclass
  
  
  @dataclass
  class Test2:
      user_id: int
      body: str
  </code></pre>
  
  <p>In this case, How can I allow pass more argument that does not define into <code>class Test2</code>?</p>
  
  <p>If I used <code>Test1</code>, it is easy. Just add <code>**kwargs(asterisk)</code> into <code>__init__</code></p>
  
  <pre><code>class Test1:
      def __init__(self, 
          user_id: int = None,
          body: str = None,
          **kwargs):
          self.user_id = user_id
          self.body = body
  </code></pre>
  
  <p>But using dataclass, Can't found any way to implement it.</p>
  
  <p>Is there any solution here?</p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>class Test1:
      def __init__(self,
          user_id: str = None, 
          body: str = None):
          self.user_id = user_id
          self.body = body
  
  if __name__ == '__main__':
      temp = {'user_id': 'hide', 'body': 'body test'}
      t1 = Test1(**temp)
      print(t1.__dict__)
  </code></pre>
  
  <p>Result : <code>{'user_id': 'hide', 'body': 'body test'}</code></p>
  
  <p>As you know, I want to insert data with dictionary type -> <code>**temp</code></p>
  
  <p>Reason to using asterisk in dataclass is the same.</p>
  
  <p>I have to pass dictinary type to class init.</p>
  
  <p>Any idea here?</p>