[Tutor] problem importing class

Jason Massey jason.massey at gmail.com
Thu Oct 26 18:21:18 CEST 2006


Shawn,

Python already has a module called site.  From
http://docs.python.org/lib/module-site.html :
*
This module is automatically imported during initialization.* The automatic
import can be suppressed using the interpreter's *-S* option. Importing this
module will append site-specific paths to the module search path.

Easiest thing would be to rename your module.


On 10/26/06, shawn bright <nephish at gmail.com> wrote:
>
> 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
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061026/99b80aeb/attachment.htm 


More information about the Tutor mailing list