Looking for an elegant way to create a URL by reading in values from a config file.
If I have the following three fields in a config file:
query1=
query2=
query3=
And I want to add them to a BASE_URL if they exist, what is an elegant way to do this?
I know there is an ugly answer like:
url +='?query1={}'.format(param1) if param1 and Not param2 or param3
url +='?query1={}&query2={}'.format(param1,param2) if param1 and param2 and Not param3
etc...
Is there an elegant pythonic solution to this? A way to abstract this idea? Thank you.