[Tutor] need some class / module help
shawn bright
nephish at gmail.com
Fri Oct 20 18:21:31 CEST 2006
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 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061020/3b86e3d6/attachment.html
More information about the Tutor
mailing list