oh, one more thing.
these objects are going to be created at the rate of about 20 / minute in a thread.
at some point is this going to be a problem ? do they go away over time?
Or do i need to write something that will kill them?

thanks
sk

On 10/20/06, shawn bright <[EMAIL PROTECTED]> wrote:
Hey thanks for the help,
yes, the class in in another file called group. the class Group is the only class in the module. I am doing this because the script that will call it is not the only place in all our scripts where it can be used. I have been doing stuff with python for over a year now, thought i would take advantage of some stuff that might save me some time.

thanks again
shawn


On 10/20/06, Bob Gailer < [EMAIL PROTECTED]> wrote:
shawn bright wrote:
Hey there,

I am trying to create a module with one class
the module name is group.py

it looks like this so far

import DbConnector

class Group(object):

    def __init__(self, id):
        self.id = id
        con = DbConnector.DbConnector()
        query = con.getOne("select `name`, `position` from `groups` where `id` = '"+id+"' ")
        self.name = query[0]
        self.position = query[1]

    def set_position(position):
        self.position = position
        con.update("update `groups` set `position` = '"+self.position+"' where `id` = '"+self.id"' ")

now lets say i wanted to do
mygroup = Group.group(12)
position = mygroup.position() # gives me position of group where id = 12
mygroup.set_position(13) # changes value of position to 13
    Is this code in another module?
    If so you need:
import group
   and
mygroup = Group.group(12)
   should be (module name followed by class name)
mygroup = group.Group(12).

mygroup.position() # this is a call, and position is not callable.
    should be
mygroup.position

"select `name`, `position` from `groups` where `id` = '"+id+"' "
    is OK but an easier to read version is:
"select `name`, `position` from `groups` where `id` = '%s'" % (id,)

is this right?
i would test it here, but the database is not available. I am writing this to implement an easier way to code something very long later.

Just wanted to know if i am on the right track.

if you have read this far, thanks !

sk






_______________________________________________
Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor


-- 
Bob Gailer
510-978-4454



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to