[Zope] basis Zope/Python script question
Steve Spicklemire
steve@spvi.com
Tue, 27 Nov 2001 11:02:43 -0500
Hi Het,
How about:
v1, v2, v3 = map(request.get, ['v1','v2','v3'], [-1]*3)
-steve
On Tuesday, November 27, 2001, at 09:58 AM, H.de.Wit@SFK.NL wrote:
> 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
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )