How to mix two lists with different lengths

Here is one interesting problem I was facing today. We have to lists, each may have a different size, and we want to mix their elements together forming a single list. We also want to keep the relative order of the elements, but more than that, we want the position from each element in the […]

Posted at 23:28 on 2013/08/08 | Leave a comment | Filed Under: Uncategorized | Tagged: , , | Continue reading

How to read a chunk of lines from a file in Python

This article shows a Python generator that lets you read lines from a file, splitting it up in chucks, or blocks, to let you easily parallelize a program to analyze a very large file, without having to split that file in separate smaller files first.

Posted at 17:02 on 2013/04/13 | 6 comments | Filed Under: Multiprocessing, Python | Continue reading

About

I’m Nic, and this blog is my little “programming tricks” notebook. Whenever I see a cool piece of code I find interesting or useful I post it here, with theoretical remarks when appropriate. May post opinion pieces about technology too sometimes. — Nicolau Werneck <nwerneck@gmail.com>


Follow

Get every new post delivered to your Inbox.

Join 312 other followers