oh, one more thing.<br>these objects are going to be created at the rate of about 20 / minute in a thread.<br>at some point is this going to be a problem ? do they go away over time?<br>Or do i need to write something that will kill them?
<br><br>thanks<br>sk<br><br><div><span class="gmail_quote">On 10/20/06, <b class="gmail_sendername">shawn bright</b> <<a href="mailto:nephish@gmail.com">nephish@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey thanks for the help, <br>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.
<br><br>thanks again<br><span class="sg">shawn</span><div><span class="e" id="q_10e66e02622c4c7f_2"><br><br><div><span class="gmail_quote">On 10/20/06, <b class="gmail_sendername">Bob Gailer</b> <<a href="mailto:bgailer@alum.rpi.edu" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
bgailer@alum.rpi.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"><span>
shawn bright wrote:
<blockquote cite="http://mid384c93600610200921p4a3d3b50vd18b84871ca52e9c@mail.gmail.com" type="cite">Hey there,<br>
<br>
I am trying to create a module with one class<br>
the module name is group.py<br>
<br>
it looks like this so far<br>
<br>
import DbConnector<br>
<br>
class Group(object):<br>
<br>
def __init__(self, id):<br>
<a href="http://self.id" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">self.id</a> = id<br>
con = DbConnector.DbConnector()<br>
query = con.getOne("select `name`, `position` from `groups`
where `id` = '"+id+"' ")<br>
<a href="http://self.name" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
self.name</a> = query[0]<br>
self.position = query[1]<br>
<br>
def set_position(position):<br>
self.position = position<br>
con.update("update `groups` set `position` =
'"+self.position+"' where `id` = '"+self.id"' ")
<br>
<br>
now lets say i wanted to do <br>
</blockquote>
<blockquote cite="http://mid384c93600610200921p4a3d3b50vd18b84871ca52e9c@mail.gmail.com" type="cite">mygroup = Group.group(12)<br>
position = mygroup.position() # gives me position of group where id = 12<br>
mygroup.set_position(13) # changes value of position to 13<br>
</blockquote></span>
Is this code in another module? <br>
If so you need:<br>
import group<br>
and <br>
mygroup = Group.group(12) <br>
should be (module name followed by class name)<br>
mygroup = group.Group(12).<br>
<br>
mygroup.position() # this is a call, and position is not callable.<br>
should be <br>
mygroup.position<span><br>
<br>
"select `name`, `position` from `groups` where `id` = '"+id+"' "<br></span>
is OK but an easier to read version is:<br>
"select `name`, `position` from `groups` where `id` = '%s'" % (id,)
<blockquote cite="http://mid384c93600610200921p4a3d3b50vd18b84871ca52e9c@mail.gmail.com" type="cite"><span><br>
is this right?
<br>
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.<br>
<br>
Just wanted to know if i am on the right track.<br>
<br>
if you have read this far, thanks !
<br>
<br>
sk<br>
<br>
<br>
<br>
<br>
<br>
</span><pre><hr size="4" width="90%">
_______________________________________________<br>Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Tutor@python.org</a>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mail.python.org/mailman/listinfo/tutor</a>
</pre>
</blockquote>
<br>
<br>
<pre cols="72">-- <br>Bob Gailer<br>510-978-4454</pre>
</div>
</blockquote></div><br>
</span></div></blockquote></div><br>