I'm looking for an oneliner for this below logic:
links (list) variable will contain = ['**www.google.com/api/1.js**','**/path.js**']
url = "mysite.com"
valid_links = [url + u for u in links if not urlparse(u).netloc ]
This will give me only ['mysite.com/path.js'] but not 'www.google.com' in the list. I need full urls as it is and paths appended with my own url.
So i added else block:
url = "mysite.com"
valid_links = [url + u for u in links if not urlparse(u).netloc else u]
Can someone help me to get rid of the syntax error for this oneliner.
I tried it with
for #[iter]
if:
....
append to list
else:
....
append to list
But i want understand how to convert it in a oneliner