A
aking
this worked a treat:J. Clifford Dyer said:I suspect you are misusing the concept of a function. In most basic
cases, and I suspect your case applies just as well as most, a function
should take arguments and return results, with no other communication
between the calling code and the function itself. When you are inside
your function don't worry about the names of the variables outside. I'm
not sure exactly where your floats are coming from, but try something
like this:
... float1 = relevant_data * 42.0
... float2 = relevant_data / 23.0
... return float1, float2
87.0
Notice that you don't need to use the variable C (or much less the
string "C", inside monoVarCalc at all. It gets bound to the name
relevant_data instead.
Also, if you are going to have a lot of these little results lying
around, (Cab, Cac ... Czy, Czz), you might consider making them a list
or a dictionary instead. I won't tell you how to do that, though. The
online tutorial has plenty of information on that.
http://docs.python.org/tut/tut.html
Cheers,
Cliff
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')
thanks
Ali
--
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