Fix Python – How to get everything after last slash in a URL?

How can I extract whatever follows the last slash in a URL in Python? For example, these URLs should return the following:
URL: http://www.test.com/TEST1
returns: TEST1

URL: http://www.test.com/page/TEST2
returns: TEST2

URL: http://www.test.com/page/page/12345
returns: 12345

I’ve tried urlparse, but that gives me the full path filename, such as….

Fix Python – How to join components of a path when you are constructing a URL in Python

For example, I want to join a prefix path to resource paths like /js/foo.js.
I want the resulting path to be relative to the root of the server. In the above example if the prefix was “media” I would want the result to be /media/js/foo.js.
os.path.join does this really well, but how it joins paths is OS dependent. In this case I know I am target….

Fix Python – Add params to given URL in Python

Suppose I was given a URL.
It might already have GET parameters (e.g. http://example.com/search?q=question) or it might not (e.g. http://example.com/).
And now I need to add some parameters to it like {‘lang’:’en’,’tag’:’python’}. In the first case I’m going to have http://example.com/search?q=question&lang=en&tag=python and in the second — http:/….