carbontracking
carbontracking

Reputation: 1089

When using web.py how can I checkis a parameter exists in the URL?

I'm using web.py https://webpy.org/ for providng access to simple python script like http://hosturl.com.scriptname?param1=something&param2=somethingelse

I see how I can retrieve the values of the parameters using

import web
param1 = web.input().param1
param2 = web.input().param2

However I'm stuck when I try to check if the param2, for example, even exists.

I've tried

if web.input().param2:

but that gives me an error message

<class 'AttributeError'> at /getmonthlyPV

Upvotes: 0

Views: 35

Answers (1)

carbontracking
carbontracking

Reputation: 1089

Groan....

what I needed was

if hasattr(web.input(),"param2"):

Alot to be said for reading the error messages, they're actually trying to help :(

Upvotes: 0

Related Questions