Skip to content

Commit

Permalink
Use "pycon" syntax lexer for REPL snippets in README
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz authored May 27, 2020
2 parents fa2e925 + 312d385 commit d592009
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ yarl
Introduction
------------

Url is constructed from ``str``::
Url is constructed from ``str``:

.. code-block:: pycon
>>> from yarl import URL
>>> url = URL('https://www.python.org/~guido?arg=1#frag')
>>> url
URL('https://www.python.org/~guido?arg=1#frag')
All url parts: *scheme*, *user*, *password*, *host*, *port*, *path*,
*query* and *fragment* are accessible by properties::
*query* and *fragment* are accessible by properties:

.. code-block:: pycon
>>> url.scheme
'https'
Expand All @@ -49,28 +53,36 @@ All url parts: *scheme*, *user*, *password*, *host*, *port*, *path*,
>>> url.fragment
'frag'
All url manipulations produce a new url object::
All url manipulations produce a new url object:

.. code-block:: pycon
>>> url.parent / 'downloads/source'
URL('https://www.python.org/downloads/source')
Strings passed to constructor and modification methods are
automatically encoded giving canonical representation as result::
automatically encoded giving canonical representation as result:

.. code-block:: pycon
>>> url = URL('https://www.python.org/путь')
>>> url
URL('https://www.python.org/%D0%BF%D1%83%D1%82%D1%8C')
Regular properties are *percent-decoded*, use ``raw_`` versions for
getting *encoded* strings::
getting *encoded* strings:

.. code-block:: pycon
>>> url.path
'/путь'
>>> url.raw_path
'/%D0%BF%D1%83%D1%82%D1%8C'
Human readable representation of URL is available as ``.human_repr()``::
Human readable representation of URL is available as ``.human_repr()``:

.. code-block:: pycon
>>> url.human_repr()
'https://www.python.org/путь'
Expand Down

0 comments on commit d592009

Please sign in to comment.