title: Partial function object has no attribute "__code__"
body: <p>I am writing a small application that takes users' input to give them a set of optimal parameters to use. (Each of these sets are ranked and the user can select whichever one they want to use)</p>
  
  <p>To be able to do this, I select one function from an array of choices(depending on the context), partially fill the function using <code>functools.partial</code> then return the partial object to another module which in turn calls a C++ library (<code>dlib</code>) which has a python interface. </p>
  
  <p>Up until today, I wasn't using <code>functools.partial</code> to fill the function and faced no issues. But to make the code less repetitive and easier to understand, I added that in. After adding that part, I get the following error :</p>
  
  <blockquote>
    <p>AttributeError: 'functools.partial' object has no attribute '__code__'</p>
  </blockquote>
  
  <p>I read a few posts and realized that this is an issue with <code>partial</code> objects as they often lack attributes like <code>__name__</code>, <code>__module__</code> etc but I am not sure how to resolve this issue. </p>
  
  <p>PS: I am using python 3.7</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am adding a small code that reproduces the error</p>
  
  <pre><code>from functools import partial
  from sklearn.linear_model import LogisticRegression
  from sklearn.metrics import accuracy_score
  from sklearn.datasets import load_breast_cancer
  from dlib import find_max_global
  
  def objective_calculator(*args, X, y):
      args = args[0]
      model = LogisticRegression()
      model.set_params(**{'class_weight': args[0], 'max_iter':args[1]})
      model.fit(train['data'], train['target'])
      predictions = model.predict(X)
      return accuracy_score(y, predictions)
  
  train = load_breast_cancer()
  obj_calc = partial(objective_calculator, X=train['data'], y=train['target'])
  lower_bounds = [0.1, 10] # class_weight, max_iter
  upper_bounds = [0.5, 200] # class_weight, max_iter
  is_integer_variable = [False, True]
  
  find_max_global(f=obj_calc,
                  bound1=lower_bounds,
                  bound2=upper_bounds,
                  num_function_calls=2,
                  is_integer_variable=is_integer_variable,
                  solver_epsilon=1,)
  </code></pre>
  
  <p>Running the above code results in the following error</p>
  
  <blockquote>
    <p>AttributeError: 'functools.partial' object has no attribute '__code__'</p>
  </blockquote>
  
  <p>Is it advisable to manually add the <code>__code__</code> attribute to the partial object?</p>