Skip to content

Commit

Permalink
add Python 3.6 compatible code to example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
dansan committed Dec 6, 2019
1 parent a904ae8 commit d75b88e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Usage

The ``UDM`` context manager opens and closes a HTTP session::

>>> import asyncio
>>> from udm_rest_client.udm import UDM
>>>
>>> async def get_obj(mod_name, dn):
Expand All @@ -37,8 +38,13 @@ The ``UDM`` context manager opens and closes a HTTP session::
... mod = udm.get(mod_name)
... return await mod.get(dn)
...
>>> import asyncio
>>> # Python 3.6:
>>> loop = asyncio.get_event_loop()
>>> obj = loop.run_until_complete(get_obj("users/user", "uid=foo,cn=users,BASE-DN"))
>>>
>>> # Python 3.7+:
>>> obj = asyncio.run(get_obj("users/user", "uid=foo,cn=users,BASE-DN"))
>>>
>>> print(obj)
UdmObject('users/user', 'uid=foo,cn=users,BASE-DN')
>>> print(obj.props.username)
Expand Down

0 comments on commit d75b88e

Please sign in to comment.