Skip to main content

Better URI Handling

Project description


[![Build Status](](
[![Coverage Status](](
[![PyPI version](](

Better URI handling

Tested with Python 2.7 and 3.6


## Install

`pip install pyuri`

## Usage

Raw URI string parsing:

from pyuri import URI

uri = URI('http://localhost:80/path/to/file?query=value#/fragment/path')

assert uri.scheme == 'http'
assert == 'localhost'
assert uri.port == 80
assert uri.path == '/path/to/file'
assert uri.query == 'query=value'
assert uri.fragment == '/fragment/path'

Composition by parts

from pyuri import URI

uri = URI(scheme='ftp', host='localhost', port=8000, query='key=value')

assert str(uri) == 'ftp://localhost:8000?key=value'

Modification and comparison

from pyuri import URI

uri1 = URI('')
uri2 = URI('')

assert uri1 != uri2

uri1.port = 443
uri1.path = '/new/path'

assert str(uri1) == ''

assert uri1 == uri2

Additional helpers

from pyuri import URI

uri = URI('http://localhost:80/path/to/file?repeat=value1&repeat=value2&escape=escaped%20value#/fragment/path')

# Access query parameters as dictionary
assert uri.query_dict() == {
'repeat': ['value1', 'value2'],
'escape': ['escaped value']

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyuri, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size pyuri-0.3.1-py2.py3-none-any.whl (6.2 kB) File type Wheel Python version 3.6 Upload date Hashes View
Filename, size pyuri-0.3.1.tar.gz (7.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page