diff --git a/docs/usage/advanced_usage.rst b/docs/usage/advanced_usage.rst index bdb0b23..df3bc48 100644 --- a/docs/usage/advanced_usage.rst +++ b/docs/usage/advanced_usage.rst @@ -59,15 +59,10 @@ with a status update. .. code-block:: python - # Assume you are working with a JPEG + # Assuming that you are working with a JPEG from PIL import Image - try: - # Python 3 - from io import StringIO - except ImportError: - # Python 2 - from StringIO import StringIO + from io import BytesIO photo = Image.open('/path/to/file/image.jpg') @@ -76,14 +71,13 @@ with a status update. height = int((float(photo.size[1]) * float(wpercent))) photo = photo.resize((basewidth, height), Image.ANTIALIAS) - image_io = StringIO.StringIO() + image_io = BytesIO() photo.save(image_io, format='JPEG') # If you do not seek(0), the image will be at the end of the file and # unable to be read image_io.seek(0) - response = twitter.upload_media(media=image_io) twitter.update_status(status='Checkout this cool image!', media_ids=[response['media_id']])