[Zope] basis Zope/Python script question
H.de.Wit@SFK.NL
H.de.Wit@SFK.NL
Tue, 27 Nov 2001 15:58:53 +0100
Hello,
I write the following code repeatedly:
if request.has_key('v1'):
v1=request.v1
else:
v1=-1
if request.has_key('v2'):
v2=request.v2
else:
v2=-1
etc.
Is there a way to do this more efficient and clean, something like this:
for reqvar in ['v1','v2','v3']:
if request.haskey(reqvar):
reqvar=request.reqvar #this doesn't work
else
reqvar=-1 # and this also not.
Het vriendelijke groeten,
Hans de Wit
Stichting Farmaceutische Kengetallen
Postbus 30460
2500 GL DEN HAAG
Tel. 070-3737448
Fax 070-3737445