Question: I am having a simple doubt..
 I am trying to join three parts of a string using urljoin..

```
   host = "http://foo.com:port"
   ver = "/v1"
   exten = "/path"

```

Rather than doing host+ver+exten, I want to use urljoin to generate url
 But urljoin is giving 
 `http://foo.com:poort/v1` ( if i try `urljoin(host,ver,exten)` )

Answer: 
Here's one way to do it on linux(python 2.x):

```
import urlparse
import os
def url_join(host, version, *additional_path):
    return urlparse.urljoin(host, os.path.join(version, *additional_path))

```

and then call this function like:

```
>> url_join("http://example.com:port", "v1", "path1", "path2", "path3")
>> 'http://example.com:port/v1/path1/path2/path3

```
You could use the [str.**join**](https://docs.python.org/3/library/stdtypes.html#str.join) function, as suggested in this other [answer](https://stackoverflow.com/a/36189633):

```
url = urljoin('http://example.com:port', '/'.join(['v1','path']))

```

If the path segments contains one or more slash `/`, use [str.**strip**](https://docs.python.org/3/library/stdtypes.html#str.strip) first:

```
path='/'.join(map(lambda s: s.strip('/'), ["/v1", "/path"]))
url = urljoin('http://example.com:port', path)

```