[Tutor] problem importing class

shawn bright nephish at gmail.com
Thu Oct 26 18:07:22 CEST 2006


hey there

i have written a module called site.py
in the file i have this:

import DbConnector
import sensor

class Site(object):
    "site object"

    def __init__(self, id):
        self.id = id
        self.con = DbConnector.DbConnector()
        id = str(self.id)
        stats = self.con.getOne("selct `group_id`, `name`, `ivr_code`, \
            `site_type`, `notes`, `sensor_id` \
            from `sites` where `id` = '"+str(id)+"' ")
        self.group_id = stats[0]
        self.name = stats[1]
        self.ivr_code = stats[2]
        self.site_type = stats[3]
        self.notes = stats[4]
        self.sensor_id = stats[5]

    def get_sensor(self):
        self.sensor = sensor.Sensor(self.sensor_id)
        return self.sensor

ok, in the program i am trying to run i have these lines:
import site
new_site = site.Site(id_number)

and this is what my output is:
Traceback (most recent call last):
  File "./new_camp.py", line 2014, in on_site_tree_view_row_activated
    acitve_site = site.Site(id_number)
AttributeError: 'module' object has no attribute 'Site'

It looks like the same code works for a different module i have ;
i don't get what i could be missing here, any tips?

if you have read this far, thanks for your time.
sk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061026/17139a00/attachment.html 


More information about the Tutor mailing list