title: Using google.protobuf.Any in python file
body: <p>I have such <code>.proto</code> file</p>
  
  <pre><code>syntax = "proto3";
  import "google/protobuf/any.proto";
  
  message Request {
    google.protobuf.Any request_parameters = 1;
  }
  </code></pre>
  
  <p>How can I create <code>Request</code> object and populate its fields? I tried this:</p>
  
  <pre><code>import ma_pb2
  from google.protobuf.any_pb2 import Any
  
  parameters = {"a": 1, "b": 2}
  Request = ma_pb2.Request()
  some_any = Any()
  some_any.CopyFrom(parameters)
  Request.request_parameters = some_any
  </code></pre>
  
  <p>But I have an error:</p>
  
  <pre><code>TypeError: Parameter to CopyFrom() must be instance of same class: expected google.protobuf.Any got dict.
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Following prompts of @Kevin I added new message to <code>.proto</code> file:</p>
  
  <pre><code>message Small {
    string a = 1;
  }
  </code></pre>
  
  <p>Now code looks like this:</p>
  
  <pre><code>Request = ma_pb2.Request()
  small = ma_pb2.Small()
  small.a = "1"
  
  some_any = Any()
  some_any.Pack(small)
  
  Request.request_parameters = small
  </code></pre>
  
  <p>But at the last assignment I have an error:</p>
  
  <pre><code>Request.request_parameters = small
  AttributeError: Assignment not allowed to field "request_parameters" in protocol message object.
  </code></pre>
  
  <p>What did I do wrong?</p>