Entries tagged with “Python”.


This week we welcome Chris Withers as our PyDev of the Week! Chris has been using Python for quite a while. I think the first packages I used of his were the excellent xlrd and xlwt packages, used for reading and writing Excel files. You can get an idea of his contributions to Python on his github profile. Let’s take some time and get to know him better.

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

I grew up in Zimbabwe and now like in the UK, but have ended up with two passports, both for countries I’ve never lived in.

When I’m not coding, I’m either umpiring for field hockey matches or doing things with dance music.

(more…)

Earlier this week, I came across another fun package called datefinder. The idea behind this package is that it can take any string with dates in it and transform them into a list of Python datetime objects. I would have loved this package at my old job where I did a lot of text file and database query parsing as there were many a time when finding the date and getting it into a format I could easily use was quite the nuisance.

Anyway, to install this handy package all you need to do is this:


pip install datefinder

I should note that when I ran this, it ended up also installing the following packages:

  • PyYAML-3.11
  • dateparser-0.3.2
  • jdatetime-1.7.2
  • python-dateutil-2.4.2
  • pytz-2015.7
  • regex-2016.1.10
  • six-1.10.0
  • umalqurra-0.2

Because of all this extra stuff, you might want to install this package into a virtualenv first. Let’s take a look at some code. Here’s a quick demo I tried:

>>> import datefinder
>>> data = '''Your appointment is on July 14th, 2016. Your bill is due 05/05/2016'''
>>> matches = datefinder.find_dates(data)
>>> for match in matches:
... 	print(match)
... 
2016-07-14 00:00:00
2016-05-05 00:00:00

As you can see, it worked quite well with these two common date formats. Another format that I used to have to support was the fairly typical ISO 8601 date format. Let’s see how datefinder behaves with that.

>>> data = 'Your report is due: 2016-02-04T20:16:26+00:00'
>>> matches = datefinder.find_dates(x)
>>> for i in matches: 
...     print(i)
... 
2016-02-04 00:00:00
2016-02-04 20:16:26

Interestingly, this particular version of the ISO 8601 format causes datefinder to return two matches. The first is just the date while the second has both the date and the time. Anyway, hopefully you’ll find this package useful in your projects. Have fun!

Webucator recently contacted me to let me know that they have finished up an Introduction to Python Training that they are allowing people to take for free for the month of February. The course is made up of videos, exercises, readings, and quizzes. You can get it free by using the following code when you register: PYTHON

I thought they did a good job when they did a video based on my context manager article.

This week we welcome Oliver Schoenborn as our PyDev of the Week. He is the author of the PyPubSub project, a version of which is included with wxPython. He has been an active contributor on the wxPython mailing list where I have always appreciated his insights. You might find his Dr. Dobbs article interesting as well, even though it’s a bit old. Let’s spend a few moments getting to know him better!

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

I’m a Senior Consultant at CAE Inc in Ottawa, where I engineer simulation systems for a variety of applications.

I started programming on an Apple IIe in 1982 when I was 13 years old. I bought it used, with my own money that I had saved for a few years for “some day when I would want something really big”. I discovered Assembly programming on that machine, with peeks and pokes and interrupts and registers, and was hooked. I moved on to Basic and Pascal and Prolog. I created my first simulation in my last year of high-school for a programming course project. Discovering C++ in the mid-90’s was a revelation, I found the object-oriented approach so intuitive, and I’m still a stickler for clean interfaces and refactoring. During my high-school years I thought that Physics was my passion and I received my Physics PhD in 1998 from University of Toronto, but I came to realize that programming was my real passion and have made that the focus of my professional career.

I haven’t worked in Physics since my degree, but during my PhD I developed many valuable skills such as problem solving, bug finding, testing, approximations, process modeling, and Unix development. As such, I have been fortunate to work on some very fun and challenging industrial projects, including: crane operation trainer in a fully immersive virtual environment (with a real crane cab and controls, and surround display etc);a Search and Rescue trainer which allows an instructor to challenge a student to spot and alert against threats on a military aircraft; an Avionics maintenance trainer that allows a classroom of students to each troubleshoot defects on a modern aircraft using virtual tools and virtual cockpit and work areas and a Human Resources planner that allows an Operational Research department to conduct “what-if” analyses of 100,000 employees evolving over the span of 20-30 years in the future.

Other than an obsession for programming, I love snowboarding, and playing the harmonica (blues and folk, although I don’t have much time anymore to learn anything new). If you are middle-aged and want to learn how to snowboard without breaking your rear-end, let me know and I’ll share the tricks that allowed me to enjoy this wonderful sport.

(more…)

Every so often you will find yourself needing to write code that traverse a directory. They tend to be one-off scripts or clean up scripts that run in cron in my experience. Anyway, Python provides a very useful method of walking a directory structure that is aptly called os.walk. I usually use this functionality to go through a set of folders and sub-folders where I need to remove old files or move them into an archive directory. Let’s spend some time learning about how to traverse directories in Python!

(more…)

This week we’re doing something a little different. Instead of just one developer, I am interviewing the main developers behind xlwings: Felix Zumstein & Eric Reynolds. Let’s spend some time getting to know our fellow Pythonistas!

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

Felix: I am the founder of Zoomer Analytics, a consulting company for the development of bespoke analytical software systems. I don’t have a formal computer science background but got into application development through my previous job in a financial modeling team. My first steps were in VBA before I got pulled into Matlab which was the primary modeling language used in my team.

Eric: I am a partner at Zoomer Analytics, having joined Felix after we found we had a common vision of open-source tools that enable you to leverage the power of Python within a business context dominated by Excel. My education was in mathematics and computer science and have spent most of my professional life in a trading floor environment in quant and trading roles. Programming has always been a hobby for me since I was a kid.

(more…)

The other day, I came across an interesting project called sh, which I believe refers to the shell (or terminal). It used to be the pbs project, but they renamed it for reasons I haven’t figured out. Regardless, the sh package is a wrapper around subprocess that allows the developer to call executables a little more simply. Basically it will map your system programs to Python functions. Note that sh only supports linux and mac, whereas pbs supported Windows too.

Let’s look at a couple of examples.

>>> from sh import ls
>>> ls
<command '/bin/ls'/>
>>> ls('/home')
user_one  user_two

(more…)

This week we welcome Ian Cordasco as our PyDev of the Week. He is a very active contributor to many Python-related projects, such as Requests, Flake8, PyFlakes and much more. Let’s spend some time getting to know our fellow Pythonista!

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

My educational background is in pure and applied mathematics. While I was in college, I taught myself programming as a hobby and began contributing to various open source projects; I took over maintenance of Flake8 and became a core contributor to Requests while I was creating github3.py.

I work for Rackspace on OpenStack, our Private Cloud solution based on the OpenStack Ansible project, and other related projects.

In my free time, I:

  • work on various OSS projects (see list below)
  • mentor marginalized people looking to become OSS contributors
  • play guitar (which I’ve done since I was 7)
  • blog

(more…)

This week we welcome Fernando Doglio as our PyDev of the Week. While Fernando hasn’t been using Python for long, he did author the book, Mastering Python High Performance for Packt Publishing. If you’d like to see what Fernando has been up to, I recommend checking out his Github profile. Let’s spend some time getting to know him a bit better!

doglio

(more…)

I recently came across a post by BusinessInsider that claimed that Python was one of the top eight languages to have on your resume in 2016. Python comes in at 6th place. However, the article cites an article on CodingDojo as its source of information, which was talking about “The 8 Most In-Demand Programming Languages of 2015”. If you look at both articles, you’ll see that BusinessInsider basically just rewrote CodingDojo’s article and then redirected its readers to various Udemy courses, which is an affiliate of theirs.

I also want to point out that BusinessInsider calls Python “a scripting language like JavaScript”, which is not at all how CodingDojo described it. Python is way more than a scripting language. I’ve been using Python for almost 10 years and most of my work with Python during that time was not scripting.

Regardless, I thought you, dear reader, might find the whole thing interesting. Personally I think you should take Python for spin if you haven’t already, but I’m pretty biased.