How to call a python function from an another file
<p>I have this class in my parser.py file</p>

<pre><code>class HostInfo(object):
def __init__(self, host_id):
    self.osclass = []
    self.osmatch = []
    self.osfingerprint = []
    self.portused = []
    self.ports = []
    self.extraports = []
    self.tcpsequence = {}
    self.hostnames = []
    self.tcptssequence = {}
    self.ipidsequence = {}
    self.trace = {'port': '', 'proto': '', 'hop': []}
    self.status = {}
    self.address = []
    self.hostscript = []

    # Umit extension
    self.id = host_id
    self.comment = ''

    # XXX this structure it not being used yet.
    self.nmap_host = {
            'status': {'state': '', 'reason': ''},
            'smurf': {'responses': ''},
            'times': {'to': '', 'srtt': '', 'rttvar': ''},
            'hostscript': [],
            'distance': {'value': ''},
            'trace': {'port': '', 'proto': '', 'hop': []},
            'address': [],
            'hostnames': [],
            'ports': [],
            'uptime': {'seconds': '', 'lastboot': ''},
            'tcpsequence': {'index': '', 'values': '', 'class': ''},
            'tcptssequence': {'values': '', 'class': ''},
            'ipidsequence': {'values': '', 'class': ''},
            'os': {}
            }
</code></pre>

<p>after that it defined a function which trying to find an host id from a xml file </p>

<pre><code>def get_id(self):
    try:
        return self._id
    except AttributeError:
        raise Exception("Id is not set yet.")

def set_id(self, host_id):
    try:
        self._id = int(host_id)
    except (TypeError, ValueError):
        raise Exception("Invalid id! It must represent an integer, "
                "received %r" % host_id)
</code></pre>

<p>Now i want to use call this <code>get_id</code> function from an another file.I tried so many time but it shows an error i.e. module can't be import</p>
