Merge pull request #422 from vstoykov/fix/documentation-for-python3

Improve docs for Python 3 - files should be opened as binary
This commit is contained in:
Venelin Stoykov 2017-06-01 20:02:59 +03:00 committed by GitHub
commit 845eeab3ce
2 changed files with 3 additions and 3 deletions

View file

@ -144,7 +144,7 @@ on, or what should be done with the result; that's up to you:
.. code-block:: python
source_file = open('/path/to/myimage.jpg')
source_file = open('/path/to/myimage.jpg', 'rb')
image_generator = Thumbnail(source=source_file)
result = image_generator.generate()
@ -159,7 +159,7 @@ example, if you wanted to save it to disk:
.. code-block:: python
dest = open('/path/to/dest.jpg', 'w')
dest = open('/path/to/dest.jpg', 'wb')
dest.write(result.read())
dest.close()

View file

@ -163,7 +163,7 @@ A simple example of a custom source group class is as follows:
def files(self):
os.chdir(self.dir)
for name in glob.glob('*.jpg'):
yield open(name)
yield open(name, 'rb')
Instances of this class could then be registered with one or more spec id: