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 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 - [email protected] http://mail.python.org/mailman/listinfo/tutor
