code: def _fix_port_assignment(self):
          
  
          port_name = ''
          port_number = None
  
          if self._port:
              if isinstance(self._port, int):
                  port_number = self._port
                  port_name = get_port_name(port_number)
              elif isinstance(self._port, string_types):
                  port_name = self._port
                  port_number = get_port_number(port_name)
              else:
                  raise ValueError('Cannot assign port name/number '
                          'based on port assignment type %r' % self._port)
  
              self._port = port_number
              self._portname = port_name or ''
docs: The :attr:`port` attribute can be set either by name or by its numeric
          value. This method attempt to fix the semantics of name/number as its
          extremely convenient.