<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def search(self, query, nid=None):
 """Search for posts with ``query`` :type nid: str :param nid: This is the ID of the network to get the feed from. This is optional and only to override the existing `network_id` entered when created the class :type query: str :param query: The search query; should just be keywords for posts that you are looking for """

        r = self.request(
            method="network.search",
            nid=nid,
            data=dict(query=query)
        )
        return self._handle_error(r, "Search with query '{}' failed."
                                  .format(query))