menosaint
3/13/2008 10:33:00 PM
hi
I am new to python programming..I would like to call a function that
returns an integer value and a filename string as a tuple.I coded it
like this below...I want to know if this can be coded more compactly
and efficiently..(i am from java background and thus code often
becomes bulky ..)
def mycallerfunction():
matchvalue,matchfilename=findmatchingfile()
if not matchfilename:
print "no match found"
dosomething()
else:
print "match found:",matchfilename,"with matching
distance:",matchvalue
dosomethingelse()
def findmatchingfile():
# calculate matchdistance and matchfilename and return as tuple
# if matchdistance found is not within a threshold then filename
# may be "" (an empty string)
...
...
resultname="""
matchdistance,index=dosomecalculations()
if (matchdistance < threshold):
resultname=filenameslist[index]
return (matchdistance,resultname)
if you can give some advice/suggestions it wd be great
thankx
-vincent