Re: create global variables?
- From: Alistair King <alistair.king@xxxxxxxxxxx>
- Date: Tue, 31 Oct 2006 11:46:14 +0200
Steve Holden wrote:
aking@xxxxxxxxxxxxxxxxx wrote:Yup...it works..but now i have to create a dictionary of 'a' and 'm',
J. Clifford Dyer wrote:
Alistair King wrote:
[... advice and help ...]
this worked a treat:In which case I suspect you will find that this works just as well:
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')
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
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
.
- Prev by Date: Re: 3d programming without opengl
- Next by Date: Re: create global variables?
- Previous by thread: Re: create global variables?
- Next by thread: Re: create global variables?
- Index(es):
Relevant Pages
|