Category Archives: Python

Is related to the Python Programming language in some way

PyDev of the Week: Nicole Harris

This week we welcome Nicole Harris (@nlhkabu) as our PyDev of the Week! Nicole is the lead designer of Warehouse, the replacement for the Python Packaging Index (PyPI). You can see a demo version of the site here. She is also working with O’Reilly publishing on a Django screencast, which you’ll hear more about below. Nicole also has a fun blog that is well worth checking out. Let’s take a few moments to get to know her better!

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

I’ve always been a creative person. I studied film and photography at university and got into web design (which eventually led me to Python) because I wanted to create an online portfolio of my animation works. I never launched that portfolio – but I did fall in love with the web.

In my spare time, I like to cook and sew. I’m also learning to speak French.

Continue reading PyDev of the Week: Nicole Harris

Python 201: An Intro to itertools

Python provides a great module for creating your own iterators. The module I am referring to is **itertools**. The tools provided by itertools are fast and memory efficient. You will be able to take these building blocks to create your own specialized iterators that can be used for efficient looping. In this chapter, we will be looking at examples of each building block so that by the end you will understand how to use them for your own code bases.

Let’s get started by looking at some infinite iterators!

Continue reading Python 201: An Intro to itertools

PyDev of the Month: Peter Damoc

This week we welcome Peter Damoc as our PyDev of the Week! I first came across some of Peter’s work in the wxPython source code. Let’s spend some time getting to know him better!

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

I’m 39 and I’m the oldest of five. I have three sisters and a brother that’s 20 years younger than me. I finished BioMedical Engineering with a degree in BioInstrumentation and most of my working experience has been in a plastic surgery clinic. I’ve used Python to implement a distributed patient management software for internal use and a series of softwares for breast implants selection, the most famous of them being BioDynamic Breast Analysis which got distributed internationally by Allergan. For the past 4 years I’ve been in an extended sabbatical exploring a career in coaching and training. My main hobby for the past 3 years has been Argentine Tango. Continue reading PyDev of the Month: Peter Damoc

Python 201 – What’s a deque?

According to the Python documentation, deques “are a generalization of stacks and queues”. They are pronounced “deck” which is short for “double-ended queue”. They are a replacement container for the Python list. Deques are thread-safe and support memory efficient appends and pops from either side of the deque. A list is optimized for fast fixed-length operations. You can get all the gory details in the Python documentation. A deque accepts a maxlen argument which sets the bounds for the deque. Otherwise the deque will grow to an arbitrary size. When a bounded deque is full, any new items added will cause the same number of items to be popped off the other end.

As a general rule, if you need fast appends or fast pops, use a deque. If you need fast random access, use a list. Let’s take a few moments to look at how you might create and use a deque.

>>> from collections import deque
>>> import string
>>> d = deque(string.ascii_lowercase)
>>> for letter in d:
...     print(letter)

Continue reading Python 201 – What’s a deque?

PyDev of the Week: John Cook

This week we welcome John Cook as our PyDev of the Week! John has a fun Python blog that I read from to time and he graciously accepted my offer of interviewing him this week. Let’s take a few moments to get to know him better.

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

I’m a consultant working in the overlap of math, data analysis, and software development. Most projects I do have two of these elements if not all three. I had a variety of jobs before starting my own company, and most of them involved some combination of math and software development.

  Continue reading PyDev of the Week: John Cook

Python 201 Kickstarter Update – The End is Nigh!

We are entering the last few days for the Kickstarter Campaign for my second book, Python 201. Since we’re almost to our stretch goal, I have added new chapters to the book. In addition to what was already covered, the book will also cover the following topics:

  • Python’s super()
  • descriptors (magic methods)
  • Scope (local, global and the new non_local)
  • typing
  • asyncio / await / async

That brings the total number of chapters up to 27! If you feel like contributing, you can do so here: https://www.kickstarter.com/projects/34257246/python-201-intermediate-python

PyDev of the Week: Thomas Robitaille

This week we welcome Thomas Robitaille (@astrofrog) as our PyDev of the Week! Thomas is the lead developer of the Glue data exploration package and one of the lead developers of the Astropy project, which is a Python library for Astronomy. He also writes a fun Python blog. Let’s take a few moments to get to know our fellow Pythonista better!

 

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

I am currently a freelance scientific software developer, working on projects with teams in North America and in Europe. However, this is a very recent development: until the end of 2015, I was an astrophysicist, and I worked mainly on studying the formation of stars and on radiative transfer. I completed my PhD in the UK in 2008, then worked as a researcher at Harvard and subsequently at the Max Planck Institute for Astronomy in Germany. During my time as a researcher, I learned Python and became involved in a number of open-source scientific software projects. In particular, I actively participated in efforts to build Python tools for astronomy and encourage astronomers to learn Python, and I became one of the coordinators and lead developers for the Astropy project. I eventually decided that I wanted to work on scientific software development full time, and made the jump to work as a freelance developer!

 

Continue reading PyDev of the Week: Thomas Robitaille

Python 201 Kickstarter Update #3 – Cover Almost Done!

My artist got back to me today with a mostly done cover that I wanted to share with you all:

Python 201 Cover

We have 8 days left in the campaign and we’re almost to our stretch goal! Be sure to tell your friends that now’s the best time to show support for this fun book! You can pledge support here.

Python 201 – What is a ChainMap?

A ChainMap is a class from the collections module that provides the ability to link multiple mappings together such that they end up being a single unit. If you look at the documentation, you will notice that it accepts *maps, which means that a ChainMap will accept any number of mappings or dictionaries and turn them into a single view that you can update. Let’s look at an example so you can see how this works:

>>> from collections import ChainMap
>>> car_parts = {'hood': 500, 'engine': 5000, 'front_door': 750}
>>> car_options = {'A/C': 1000, 'Turbo': 2500, 'rollbar': 300}
>>> car_accessories = {'cover': 100, 'hood_ornament': 150, 'seat_cover': 99}
>>> car_pricing = ChainMap(car_accessories, car_options, car_parts)
>>> car_pricing['hood']
500

Here we import ChainMap from our collections module. Next we create three dictionaries. Then we create an instance of our ChainMap by passing in the three dictionaries that we just created. Finally, we try accessing one of the keys in our ChainMap. When we do this, the ChainMap will go through each map in order to see if that key exists and has a value. If it does, then the ChainMap will return the first value it finds that matches that key.

Continue reading Python 201 – What is a ChainMap?

PyDev of the Week: Ezio Melotti

This week we welcome Ezio Melotti as our PyDev of the Week! Ezio is a core developer of the Python language. You can get an idea of what he’s been up to via his bitbucket page. Let’s take a few moments to get to know him!

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

At the moment I live in Finland, where I studied and graduated in Information Technology. While I was graduating I taught a university course on Python programming and now I work remotely as a developer/educator.

I’ve been a CPython core developer since 2009 and I’m the maintainer of the bug tracker and the html package. I spend a good slice of my free time improving Python in different ways, including work on the stdlib, documentation, tests, infrastructure, mentoring for Google Summer of Code, organizing sprints, and doing talks at conferences.

My hobbies include traveling, learning new languages (Chinese and Spanish), and wildlife photography.

Continue reading PyDev of the Week: Ezio Melotti