Category Archives: Python

Is related to the Python Programming language in some way

Filling PDF Forms with Python

Fillable forms have been a part of Adobe’s PDF format for years. One of the most famous examples of fillable forms in the United States are documents from the Internal Revenue Service. There are lots of government forms that use fillable forms. There are many different approaches for filling in these forms programmatically. The most time consuming method I have heard about is to just recreate the form in ReportLab by hand and then fill it in. Frankly I think this is probably the worst idea, except when your company is in charge of creating the PDFs itself. Then that might be a viable option because you then have complete control over the PDF creation and the inputs that need to go into it.


Creating a Simple Form

We need a simple form to use for our first example. ReportLab has built-in support for creating interactive forms, so let’s use ReportLab to create a simple form. Here is the code: Continue reading Filling PDF Forms with Python

PyDev of the Week: Kai Willadsen

This week we welcome Kai Willadsen (@kywe) as our PyDev of the Week! He is the maintainer of the Meld project, a cross-platform visual diff and merge tool written in Python. You can catch up with Kai on his blog or see what else he is working on via Github. Let’s take a few moments to get to know Kai better.

Can you tell us a little about yourself (hobbies, education, etc):

I did undergrad in computer science + cognitive science, a PhD in complex systems modeling, and a variety of post-doc work before bailing on the academic life. None of the above is even remotely relevant to my current work though!

My non-computer hobbies are basically gardening & chicken keeping. For people in the position to do so: if you’ve never kept chickens, think about it! They are the best. Continue reading PyDev of the Week: Kai Willadsen

PyCon 2018 – Conference Day 3 (May 13)

Day 3 of PyCon 2018 began with a keynote from one of the longtime core developers of Python, Brett Cannon. He spoke on the struggles of working in open source and how we should treat each other with kindness throughout the process. I completely agreed with all his points as the negativity I see sometimes is quite discouraging. I try hard when I review books to not be too negative, for example.

After the keynote, they had a poster session and job fair. The poster session is reserved for people who weren’t chosen to give a talk, but their proposal was still good enough for a poster. Or at least, that’s how it was explained to me when the first poster session occurred. I did notice that one of the talk speakers had a poster with the same name as her talk from the previous day, so maybe the rules have changed? I don’t know. I think my favorite was one about a Python keyboard where the keys were remapped to make it easier to program in Python. She had certainly done her research at any rate.

The first talk I attended was Type-checked Python in the real world by Carl Meyer from Instagram. He was pretty persuasive in his talk about how powerful the typing module is and its usefulness.

I had planned to go to Ned Batchelder’s talk, Big-O: How Code Slows as Data Grows, but I got distracted by another writing open space and one on education with Python. The latter was one I probably should have skipped as it was a continuation of a previous open space.

There was a photo booth for people who wanted to take Mother’s Day photos for their loved ones and they had also set aside a room for people to call home in.

I met a ton of people this time around, which was really neat. I met a number of core developers and a couple of people who have backed my projects on Kickstarter. I even got a photo with Guido! Overall, I think I learned a lot of interesting things and look forward to interacting with the Python community for many years to come.

PyDev of the Week: Anthony Shaw

This week we welcome Anthony Shaw (@anthonypjshaw) as our PyDev of the Week! Anthony is involved in several open source projects. You can read up on all of them over on his website. He also has a blog on Medium. Let’s take a few moments to get to know Anthony better!

Can you tell us a little about yourself (hobbies, education, etc):

I started programming from an early age and got into tech at school, studied Cybernetics at University in the UK and ended up working at a Cloud company for my first job. I’ve had all sort of roles, tech support, development, product management and my latest role I’m doing “skills transformation”, which is really about helping people learn new things, encouraging people to develop their tech skills and mentoring. I don’t code day to day for work anymore since I manage a team and have a lot of travel so I typically contribute to open-source projects in spare time and in between flights.

I like to build things with my hands to switch off from work and IT, so I’m normally building something around the house, walls, landscaping or other big DIY projects. I live on the beach on the east coast of Australia so 9 months of the year I’m making any excuse to get in the water to swim. Continue reading PyDev of the Week: Anthony Shaw

PyCon 2018 – Conference Day 2 (May 12)

Day two of PyCon 2018 was kicked off with a few lightning talks. Next up were the keynotes. The first keynote was given by Ying Li from Docker. She spent her keynote talking about good security practices in the web and used a children’s book to illustrate her topic. It was kind of a fun talk and well delivered.

The second keynote was the best keynote I have seen in a long time. It was given by Qumisha Goss who is a librarian at the Detroit Public Library where she specializes in technology. She is a certified Raspberry Pi teacher and teaches Python to 6-17 years olds. It was an inspiring keynote and talked a lot about how we need to reach out across boundaries and ages and teach one another to break down barriers. I highly recommend you watch this keynote if you have a few minutes to spare! Continue reading PyCon 2018 – Conference Day 2 (May 12)

PyCon 2018 – Conference Day 1 (May 11)

PyCon 2018 in Cleveland, Ohio kicked off their first conference day with an introduction from one of Cleveland’s natives, Ernest W. Durbin III. Then we moved on to the keynote of the morning which was given by Dan Callahan from Mozilla. He talked about tooling and how Python currently doesn’t have a big presence on the web. It was actually quite interesting and also a bit disappointing as there wasn’t really a true solution given. However his talk was quite good and insightful. Continue reading PyCon 2018 – Conference Day 1 (May 11)

Determining if all Elements in a List are the Same in Python

Editor’s note: This week we have a guest post from Alex, the CEO of CheckIO

In life we always have options whether we know about them or not. It’s the same with coding. There is a fair amount of different ways in which we can approach a particular task. We might not consider those ways, or have no clue about them, but there they are. Being a coder is not just about knowing the language and the process of writing a code. Very often being a coder means being the most creative version of yourself considering what you’ve never considered before. And on this note I’d like to introduce myself. Hi! My name’s Alex, I’m a CEO at CheckiO and I’ve been dealing with the creative aspects
of this project for quite some time.

Our users are of different coding knowledge levels and experiences, that’s why I often see the standard and more obvious task solving approaches. But from time to time I come across such unique and unordinary solutions that make me once again learn new subtleties of the language.

In this article I want to go over some of the solutions to one of a very simple tasks which in my opinion are the most interesting ones. The mission requires from you to write a function that will determine whether all array elements have the same value. Continue reading Determining if all Elements in a List are the Same in Python

PyDev of the Week: Elizabeth Sander

This week we welcome Elizabeth Sander as our PyDev of the Week! Elizabeth is a data scientist at Civis Analytics. She has her own website where you can learn a lot of interesting background information about her. If you are more interested in her open source projects, then her Github profile may be what you really want to check out. Let’s take a few moments to get to know Elizabeth better!

Can you tell us a little about yourself (hobbies, education, etc):

My background is actually in computational biology, basically looking at how food webs are structured, and how to predict network structure from other kinds of data. I was bitten by the software bug in grad school. I tried to turn all of my research into software packages, or at least a series of scripts that could reproduce my work. This is surprisingly uncommon in academia, at least in ecology! I finished my Ph.D. in Ecology and Evolution last year, and now I’m a R&D data scientist at Civis Analytics. Now I get to work on software to help other data scientists do their job, which is a fun balance of programming and analysis.

I have lots of hobbies outside of software, maybe a few too many. I do a lot of circus arts, especially trapeze and contact staff, and I have a lot of crafty hobbies like sewing and knitting. I’m also a big gamer, whether it’s board games, role playing games, or video games.

Continue reading PyDev of the Week: Elizabeth Sander

Exporting Data from PDFs with Python

There are many times where you will want to extract data from a PDF and export it in a different format using Python. Unfortunately, there aren’t a lot of Python packages that do the extraction part very well. In this chapter, we will look at a variety of different packages that you can use to extract text. We will also learn how to extract some images from PDFs. While there is no complete solution for these tasks in Python, you should be able to use the information herein to get you started. Once we have extracted the data we want, we will also look at how we can take that data and export it in a different format.

Let’s get started by learning how to extract text!


Extracting Text with PDFMiner

Probably the most well known is a package called PDFMiner. The PDFMiner package has been around since Python 2.4. It’s primary purpose is to extract text from a PDF. In fact, PDFMiner can tell you the exact location of the text on the page as well as father information about fonts. For Python 2.4 – 2.7, you can refer to the following websites for additional information on PDFMiner:

PDFMiner is not compatible with Python 3. Fortunately, there is a fork of PDFMiner called PDFMiner.six that works exactly the same. You can find it here: https://github.com/pdfminer/pdfminer.six Continue reading Exporting Data from PDFs with Python

PyDev of the Week: John Reese

This week we welcome John Reese (@n7cmdr) as our PyDev of the Week. John works for Facebook and has been using Python for many years. He has a blog, but it hasn’t been updated in a while. If you’d like to see what he’s up to in open source land, then check out his Github profile. Let’s spend a few moments getting to know him better!

Can you tell us a little about yourself (hobbies, education, etc):

I like to describe myself as a Software Engineer, video game enthusiast, and virtual astronaut man_astronaut. I enjoy dabbling in photography, astronomy, and music, but I’m most passionate about technology and games. My favorite game series is Mass Effect, but I’ve spent more hours in Kerbal Space Program than any other title.

I’ve been writing software for the large majority of my life. It started when I was six, using a 286 with MS-DOS, writing batch scripts to create simple menus or boot disks for PC games of the era (640KB was never enough weary). In grade school, I started writing my own “games” in BASIC for the PC, and by early high school, I was using PHP to build my own websites and toying with C++ to write basic mods for games.

I went to university at the Rochester Institute of Technology in upstate New York, and graduated with a Software Engineering degree. Since then, I’ve worked in open source software, telecommunications, network security, and game development, mostly writing backend services or automation systems in Python.

I now live in the San Francisco bay area with my amazing wife👩🏻‍🎤 and two cats, and I work as a Production Engineer for Facebook. I’m a member of a storage team responsible for maintaining and replicating arbitrary binary data, including photos and videos for Facebook, Instagram, and WhatsApp, as well as games for the Oculus VR headsets. I’ve built a large variety of monitoring and automation systems in Python to audit the health of our service, as well as to coordinate data migrations to ensure durability and availability of data in the face of hardware failures and network outages. Continue reading PyDev of the Week: John Reese