Posts

Showing posts from December 18, 2018

Singular or plural on function that may return more than one item of a list?

Image
up vote 0 down vote favorite Given a method that returns one or more items from a list, should I name it getListItem , or getListItems ? Or, do I avoid the ambiguity and provide both methods? I'm anticipating there being a 50/50 chance of it returning one vs. multiple items. I'd like to keep my codebase concise, but ideally I wouldn't want to introduce any idiosyncratic or ambiguous naming. naming-conventions share | improve this question asked Nov 20 at 14:48 Ro Achterberg 165 1 10

Read/Open image from instance of Python io.BufferedReader class

Image
up vote 2 down vote favorite I'm struggling to properly open a TIFF image from an instance of Python's io.BufferedReader class. I download the image from a GCS path using the below lib, but I can't open seem to open the image with traditional tools. # returns the <_io.BufferedReader> file = beam.io.gcp.gcsio.GcsIO().open("<GCS_PATH>", 'r') from PIL import Image img = Image.open(file.read()) <---- Fails with "TypeError: embedded NUL character" img = Image.open(file.raw) <--- Fails when any operations are performed with "IOError(err)" I am open to other libraries besides PIL. UPDATE The following also fails: img = Image.open(file) It fails with an IOError, stating tempfile.tif: Cannot read TIFF header.