code: def replace(self, photo, photo_file, **kwds):
          
          with open(photo_file, 'rb') as in_file:
              result = self._client.post("/photo/%s/replace.json" %
                                         self._extract_id(photo),
                                         files={'photo': in_file},
                                         **kwds)["result"]
          return Photo(self._client, result)
docs: Endpoint: /photo/<id>/replace.json
  
          Uploads the specified photo file to replace an existing photo.