Compare two images the python/linux way

There is a OSS project that uses WebDriver to take screen shots and then compares the images to see if there are any issues (http://code.google.com/p/fighting-layout-bugs/)). It does it by openning the file into a stream and then comparing every bit. You may be able to do something similar with PIL. EDIT: After more research I … Read more

Can Cython compile to an EXE?

Here’s the wiki page on embedding cython Assuming you installed python to C:\Python31 and you want to use Microsoft Compiler. smalltest1.py – is the file you want to compile. test.exe – name of the executable. You need to set the environmental variables for cl. C:\Python31\python.exe C:\Python31\Scripts\cython.py smalltest1.py –embed cl.exe /nologo /Ox /MD /W3 /GS- /DNDEBUG … Read more

Compare two different files line by line in python

This solution reads both files in one pass, excludes blank lines, and prints common lines regardless of their position in the file: with open(‘some_file_1.txt’, ‘r’) as file1: with open(‘some_file_2.txt’, ‘r’) as file2: same = set(file1).intersection(file2) same.discard(‘\n’) with open(‘some_output_file.txt’, ‘w’) as file_out: for line in same: file_out.write(line)

What are dictionary view objects?

Dictionary views are essentially what their name says: views are simply like a window on the keys and values (or items) of a dictionary. Here is an excerpt from the official documentation for Python 3: >>> dishes = {‘eggs’: 2, ‘sausage’: 1, ‘bacon’: 1, ‘spam’: 500} >>> keys = dishes.keys() >>> values = dishes.values() >>> # … Read more

multiprocessing in python – sharing large object (e.g. pandas dataframe) between multiple processes

The first argument to Value is typecode_or_type. That is defined as: typecode_or_type determines the type of the returned object: it is either a ctypes type or a one character typecode of the kind used by the array module. *args is passed on to the constructor for the type. Emphasis mine. So, you simply cannot put … Read more