I have an flask API call. Here I have a request.form
data.
It looks like this:
id = request.form['id']
username = request.form['username']
password = request.form['password']
dbname = request.form['dbname']
tablename = request.form['tablename']
I want to write it in a single line in python. I tried this way but it shows error.
id,username,password,dbname,tablename = request.form['token','username','password','dbname','tablename']
I tried this. it showing error. How to achieve this...I want this to be in a single line. Is it possible in python?
Generator expression:
id, username, password, dbname, tablename = (request.form[s] for s in ('token', 'username', 'password', 'dbname', 'tablename'))
Map:
id, username, password, dbname, tablename = map(request.form.get, ('token', 'username', 'password', 'dbname', 'tablename'))