Make docs Python 3 compatible

This commit is contained in:
xtreak 2018-04-25 11:51:55 +05:30 committed by Alec Grieser
parent 2e971295fc
commit a76259022d
No known key found for this signature in database
GPG Key ID: CAF63551C60D3462
2 changed files with 7 additions and 7 deletions

View File

@ -394,8 +394,8 @@ Transactional decoration
@fdb.transactional
def simple_function(tr, x, y):
tr['foo'] = x
tr['bar'] = y
tr[b'foo'] = x
tr[b'bar'] = y
The ``@fdb.transactional`` decorator makes ``simple_function`` a transactional function. All functions using this decorator must have an argument **named** ``tr``. This specially named argument is passed a transaction that the function can use to do reads and writes.
@ -897,7 +897,7 @@ Asynchronous methods return one of the following subclasses of :class:`Future`:
@fdb.transactional
def foo(tr):
val = tr['foo']
val = tr[b'foo']
if val.present():
print 'Got value: %s' % val
else:

View File

@ -38,11 +38,11 @@ Next, we open a FoundationDB database. The API will connect to the FoundationDB
We are ready to use the database. In Python, using the ``[]`` operator on the db object is a convenient syntax for performing a read or write on the database. First, let's simply write a key-value pair:
>>> db['hello'] = 'world'
>>> db[b'hello'] = b'world'
When this command returns without exception, the modification is durably stored in FoundationDB! Under the covers, this function creates a transaction with a single modification. We'll see later how to do multiple operations in a single transaction. For now, let's read back the data::
>>> print 'hello', db['hello']
>>> print 'hello', db[b'hello']
hello world
If this is all working, it looks like we are ready to start building a real application. For reference, here's the full code for "hello world"::
@ -50,8 +50,8 @@ If this is all working, it looks like we are ready to start building a real appl
import fdb
fdb.api_version(510)
db = fdb.open()
db['hello'] = 'world'
print 'hello', db['hello']
db[b'hello'] = b'world'
print 'hello', db[b'hello']
Class scheduling application
============================