code: def shallow_copy(obj, attribute_names,
          ignore_missing_attributes=True):
      
      shallow_object = copy.copy(obj)
      shallow_object.__dict__ = {}
  
      for attribute_name in attribute_names:
          try:
              setattr(shallow_object, attribute_name, getattr(obj, attribute_name))
          except KeyError, error:
              if not ignore_missing_attributes:
                  raise error
  
      return shallow_object
docs: Return a shallow copy of the given object, including only the
      specified attributes of this object.
  
  
      @param obj: an object to copy.
  
      @param attribute_names: a list of names of the attributes to copy.
  
      @param ignore_missing_attributes: ``False`` indicates that the function
          can ignore attributes that have been specified but that are not
          defined in the given object; ``True`` indicates that the function
          MUST raise a ``KeyError`` exception if some specified attributes
          are not defined in the given object.
  
  
      @return: a shallow copy of the given object with the specified
          attributes only.
  
  
      @raise KeyError: if the argument ``ignore_missing_attributes`` equals
          ``False`` and if some specified attributes are not defined in the
          the given object.