Steve Holden wrote: > [EMAIL PROTECTED] wrote: > >> J. Clifford Dyer wrote: >> >> >>> Alistair King wrote: >>> > > [... advice and help ...] > > >> this worked a treat: >> >> def monoVarcalc(atom): >> >> a = atom + 'aa' >> Xaa = a.strip('\'') >> m = atom + 'ma' >> Xma = m.strip('\'') >> Xaa = DS1v.get(atom) >> Xma = pt.get(atom) >> return Xaa, Xma >> >> >> Caa, Cma = monoVarcalc('C') >> >> > In which case I suspect you will find that this works just as well: > > def monoVarcalc(atom): > > Xaa = DS1v.get(atom) > Xma = pt.get(atom) > return Xaa, Xma > > > Unless there is something decidedly odd about the side-effects of the > statements I've removed, since you never appear to use the values of a, > m, Xaa and Xma there seems little point in calculation them. > > regards > Steve > Yup...it works..but now i have to create a dictionary of 'a' and 'm', ie... "Xaa" and "Xma" string, key:value pairs so i can use other functions on the Xaa, Xma variables by iterating over them and retrieving the values from the variables. I think if i just input Xaa and Xma, only the values associated with those variables will go into the dictionary and ill just be iterating over nonsence.....
atomsmasses = {} def monoVarcalc(atom): a = atom + 'aa' m = atom + 'ma' atomsmasses[a]=m Xaa = a.strip('\'') Xma = m.strip('\'') Xma = pt.get(atom) if DS1v.get(atom) != None: Xaa = DS1v.get(atom) else: Xaa = 0 return Xaa, Xma Caa, Cma = monoVarcalc('C') Oaa, Oma = monoVarcalc('O') Haa, Hma = monoVarcalc('H') Naa, Nma = monoVarcalc('N') Saa, Sma = monoVarcalc('S') Claa, Clma = monoVarcalc('Cl') Braa, Brma = monoVarcalc('Br') Znaa, Znma = monoVarcalc('Zn') i think? :) thanks a -- Dr. Alistair King Research Chemist, Laboratory of Organic Chemistry, Department of Chemistry, Faculty of Science P.O. Box 55 (A.I. Virtasen aukio 1) FIN-00014 University of Helsinki Tel. +358 9 191 50392, Mobile +358 (0)50 5279446 Fax +358 9 191 50366 -- http://mail.python.org/mailman/listinfo/python-list