All posts by Mike

Getting Started with Qt for Python

The Qt Team recently posted that Qt will now be officially supporting the PySide2 project, which they are calling “Qt for Python”. It will be a complete port of the original PySide, which only supported Qt 4. PySide2 supports Qt 5. Qt for Python will have the following license types: GPL, LGPL and commercial.

PySide2 supports Python 2.7 as well as Python 3.4 – 3.6. There are snapshot wheel builds available here.Let’s say we downloaded the Windows Python wheel. To install it, you can use pip like this:

python -m pip install PySide2-5.11.0a1-5.11.0-cp36-cp36m-win_amd64.whl

Once you have PySide2 installed, we can get started by looking at a really simple example:

import sys
from PySide2.QtWidgets import QApplication, QLabel
if __name__ == '__main__':
    app = QApplication([])
    label = QLabel("Qt for Python!")

This code will create our application object (QApplication) and a QLabel to go on it. When you run app.exec_(), you start PySide2’s event loop. Since we do not specify a size for the label or the application, the size of the application defaults to be just large enough to fit the label on-screen:

Continue reading Getting Started with Qt for Python

PyDev of the Week: Andrew Knight

This week we welcome Andrew Knight (@automationpanda) as our PyDev of the Week! Andrew is an entrepreneur who co-founded Reformed Menswear and the site was created using Python and Django. If you have a moment, check out his Github profile to find out what Andrew has been contributing to. Andrew also has programming blog that you might want to see. Let’s take a few moments to get to know him better!

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

Professionally, I’m a software engineer who focuses on testing, automation, and CI/CD. My specialty is building test automation frameworks. I’ve worked at major software companies around Raleigh, NC, I run a software blog at, and I also do independent consulting.

I’m originally from Baltimore, Maryland, USA. I first got into software in 9th grade, when I learned how to program math formulas into my TI-83 Plus graphing calculator. Coding was addictive! I went on to earn a combined BS/MS in Computer Science at Rochester Institute of Technology in 2010, and I have worked in the software industry ever since.

I’m a pretty busy guy, but I enjoy cooking, craft beer, and playing Nintendo games. Right now, I’m deep into The Legend of Zelda: Breath of the Wild. I’m very active in my local church: I once served as an usher, and I’m currently teaching a class in systematic theology. My wife and I like to travel, too. We’ve been all over the USA, China, and even Thailand, with plans for more fun trips to come. Continue reading PyDev of the Week: Andrew Knight

Adding SVGs to PDFs with Python and ReportLab

ReportLab has native support for generating SVGs, but not for embedding SVGs in their PDFs. Fortunately, Dinu Gherman created the svglib package, a pure-Python package that can read SVG files and convert them to other formats that ReportLab can use. The official website for svglib is on Github.

The svglib package will work on Linux, Mac OS and Windows. The website states that it works with Python 2.7 – 3.5, but it should work in newer versions of Python as well.

You can use svglib to read your existing SVG giles and convert them into ReportLab Drawing objects. The svglib package also has a command-line tool, svg2pdf, that can convert SVG files to PDFs. Continue reading Adding SVGs to PDFs with Python and ReportLab

Splitting and Merging PDFs with Python

The PyPDF2 package allows you to do a lot of useful operations on existing PDFs. In this article, we will learn how to split a single PDF into multiple smaller ones. We will also learn how to take a series of PDFs and join them back together into a single PDF.

Getting Started

PyPDF2 doesn’t come as a part of the Python Standard Library, so you will need to install it yourself. The preferred way to do so is to use pip.

pip install pypdf2

Now that we have PyPDF2 installed, let’s learn how to split and merge PDFs!

Splitting PDFs

The PyPDF2 package gives you the ability to split up a single PDF into multiple ones. You just need to tell it how many pages you want. For this example, we will download a W9 form from the IRS and loop over all six of its pages. We will split off each page and turn it into its own standalone PDF.

Let’s find out how:

import os
from PyPDF2 import PdfFileReader, PdfFileWriter
def pdf_splitter(path):
    fname = os.path.splitext(os.path.basename(path))[0]
    pdf = PdfFileReader(path)
    for page in range(pdf.getNumPages()):
        pdf_writer = PdfFileWriter()
        output_filename = '{}_page_{}.pdf'.format(
            fname, page+1)
        with open(output_filename, 'wb') as out:
        print('Created: {}'.format(output_filename))
if __name__ == '__main__':
    path = 'w9.pdf'

Continue reading Splitting and Merging PDFs with Python

Extracting PDF Metadata and Text with Python

There are lots of PDF related packages for Python. One of my favorite is PyPDF2. You can use it to extract metadata, rotate pages, split or merge PDFs and more. It’s kind of a Swiss-army knife for existing PDFs. In this article we will learn how to extract basic information about a PDF using PyPDF2

Getting Started

PyPDF2 doesn’t come as a part of the Python Standard Library, so you will need to install it yourself. The preferred way to do so is to use pip.

pip install pypdf2

Now that we have PyPDF2 installed, let’s learn how to get metadata from a PDF! Continue reading Extracting PDF Metadata and Text with Python

Anaconda Debuts Data Science Certification Program

Anaconda put out a press release this morning that states the following:

“Anaconda, the most popular Python data science platform provider, today introduced the Anaconda Data Science Certification, giving data scientists a way to verify their proficiency, and organizations an independent standard for qualifying current and prospective data science experts.”

Anaconda is in a non-exclusive partnership with Datacamp to make this program available. Datacamp is one of the largest websites for learning about data science with the Python and R programming languages.

According to the press release, the method needed to earn the Anaconda Certified Professional (ACP) – Data Scientist designation, individuals must pass seven module exams and complete a comprehensive exam. The modules include:

  • Data import and export
  • Data manipulation and analysis
  • Visualization
  • Statistical analysis and inference
  • Machine Learning
  • Data science at scale

I know there will be businesses that will appreciate the certification. However I personally haven’t found that getting certified has helped me all that much. This might be useful but it might not. It will be interesting to hear from people who go through the certification process and see what they think of it and whether or not they thought it was worth the time and expense.

To learn more about Anaconda’s new certification program, check out the following links:

PyDev of the Week: Edward Ream

This week we welcome Edward Ream as our PyDev of the Week! Edward is the creator of the Leo (Leonine Editor with Outlines) text editor / outliner. He has been using Python since 2001. You can see what Edward has been working on over on Github. Let’s spend some time getting to know him better!

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

Ream: ​Piano, walking, science, literature, history. I read Science and Nature every week. I encourage your readers to do the same. Start with reading the summary articles and the abstract for each article. They are written for non-specialists. All scientists are lay people outside their immediate area!

I have taken piano and theory lessons for many years Michael Butkus-Bormier. He knows approximately everything about music. He’s a great jazz and classical performer. And a close friend.

I regularly do laughter yoga. It’s easily the most transformation thing I done, including the Hoffman Process and the Landmark Education Forum. I find that laughter helps me to connect with people and eases anxiety in social situations.

Laughter is a huge help to creativity.  I vividly remember a video of “Ham & Clyde” laughing while discussing their work with J. Craig Venter.  Alas, I can’t find the link.  Oh btw, Ham is a Nobelist.

I walk regularly to solve problems.  The trick is to daydream. When any relevant thought appears I write it down in a 89 cent notebook.  The idea is to forget what I have just written down so new thoughts appear.  Trying to remember things kills further daydreaming.

Rebecca is my muse.  She’s a gardener and weaver, but she asks great questions when I talk to her about Leo, even especially technical questions.  Think about how great that is!

The idea that I could use the MORE outliner as a prototype for (what became) Leo arose in conversation with her.  Very likely none of this would have happened without her.

Continue reading PyDev of the Week: Edward Ream

PyDev of the Week: Eric Snow

This week we welcome Eric Snow (@ericsnowcrntly) as our PyDev of the Week! Eric is a core developer of the Python language. You can check out his blog where he post sporadically of his Github profile where you can see what he’s currently up to. Let’s spend some time getting to know Eric better!

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

The western United States has been my home for nearly my entire life, with the exception being 2 years in Argentina before I went to college. I have a BS degree from Brigham Young University in Computer Science. I live in the mountains and enjoy spending times in the outdoors with my family. Around my home I have 17 apple tree that I take care of (and enjoy). Continue reading PyDev of the Week: Eric Snow

Talk Python Podcast and Twitter Q&A

Last week I was honored to be a part of the Talk Python to Me Podcast. During the podcast, we talked about the history of Python as well as its future. We also talked about the books I have written and how I used Kickstarter to connect with my readers. We spent some time going over my latest book, Python Interviews and some of the people I interviewed for the book. We also spoke a little about my upcoming book, ReportLab: PDF Processing in Python, which is going to be released in June 2018.

You can listen to the Podcast here:

This week, I will be doing Twitter Q&A on Wednesday, March 28th at 1 p.m. CST | 7pm BST | 11am PDT with Steve Holden and Alex Martelli in support of the Python Interviews book.. Just tweet your questions with the hashtag #PythonInterviewsQA @packtpub!

PyDev of the Week: Yusuke Tsutsumi

This week we welcome Yusuke Tsutsumi as our PyDev of the Week! Yusuke is a web developer for Zillow and has been working on open source projects for several years. He has a blog where you can learn more about him as well as various programming languages. You can also check out what projects he’s been contributing to over on Github. Let’s take some time to get to know him better!

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

I grew up in Seattle, and love the pacific northwest. After a bit of dabbling in music in high school, I landed on electrical engineering in college. I studied analog and biomedical systems (EKGs are still one of the coolest devices I’ve ever learned about). I also ended up learning about embedding systems, which, paired with some experience in college helping improve a content management system, helped me land a position at Zillow where I work today.

At work I contribute to the tooling and infrastructure used for continuous delivery, testing and monitoring, which is certainly my passion. At home, I love to read, hike, and bicycle around the city. Continue reading PyDev of the Week: Yusuke Tsutsumi