beginner: using parameter in functions
3rdshiftcoder
go at away.com
Wed May 31 19:24:01 EDT 2006
hi-
i am having trouble using parameter values in my function and to be honest a
little trouble with
member variables. i am trying to pass in the argument 'd' representing
delete.
what the code will do is if it is 'd' it will make a delete query template
string.
if it is an 'i' then insert query etc.
this is the results of my attempt to print the contents of the parameter
values.
<__main__.getQryStr instance at 0x01151D50> ('d',) me mad
(and on a side note if i dont include the *args i get an invalid number of
parameters supplied message.)
why is it returning the value in this format ('d',) ?
i cant get x == d
i guess that value 'd' is stored in a tuple and i'd like to get it out of
there.
so basically the function returns nope as it stands
python is sure different from other languages i have used.
thanks for any help,
jim
class getQryStr:
def __init__(self,op):
print op
self.x = 'd'
def returnStr(x,*args):
print '%s %s me mad' % (x,args)
if x == 'd':
s = Template("delete from columndef where tblid = $tblid and
colname = $colname")
else:
return 'nope' #this else is just for illustration and testing
d = dict(tblid=t.tblid.getText(), colname=t.colName.getText())
print s.substitute(d)
return s
def delqry(self):
createfldobj = getQryStr('d')
s = createfldobj.returnStr('d')
More information about the Python-list
mailing list