1. 程式人生 > >PyDev of the Week: Oliver Bestwalter

PyDev of the Week: Oliver Bestwalter

This week we welcome Oliver Bestwalter (@obestwalter) as our PyDev of the Week! He is one of the core developers of the tox automation project and the pytest package. He is also a speaker at several Python related conferences. You can learn more about Oliver on his website or on Github. Let’s take a few moment to learn more about Oliver!

Can you tell us a little about yourself?

I was born in West Germany on Star Wars day the year the last man set foot on the moon.

I took on my first job as a Software Developer when I was 39, right after earning my B.Sc. in Computer Engineering (in German: Technische Informatik).

Although I fell in love with computering in my early teens and with the idea of free software in my early twenties, back then I was more into music, literature and sports. In school I was led to believe that I was “not good at maths”, so studying Computer Science or anything technical was not an option. Composing and playing music dominated my teens and twenties. I played several instruments (bass, guitar and keyboards – mainly self-taught) alone, and in different bands. A few recordings from that time are online on

Soundcloud.

When I was 28 I had a nasty skateboarding accident and broke my hand and elbow. This rendered me incapable of playing any instrument for over a year. I didn’t cope with that very well and descended into a deep crisis that led me to drop music and my whole social life which had revolved around it. At that point I was pretty isolated without any kind of formal education and honestly didn’t know what to do with my life. I took on a soul-crushingly boring job in the backend (read: loud and dirty part) of a semiconductor fabrication plant. Life wasn’t that great, but in my spare time I picked up my other passion again (computering) and used it to co-found and nurture a web based, not-for-profit support board. My co-founder happened to be a wonderful woman who later became my wife. So you never know what something is good for, I guess.

I tend to turn my hobbies into my job as I did with music back then and with computering now. Good food & drink has occasionally passed my lips, which might be called a hobby, when it is not purely imbibed for sustenance. Enjoying modern art, mostly in the form of films, books, and (very seldom nowadays) computer games are also part of my recreational activities. I am more an indoor enthusiast, but I also might go for a walk now and then. Being more on the introvert spectrum, I need a lot of alone time to recharge, but I also like to hang out with my family and my cat (it might be more appropriate to say that the cat sometimes likes to hang out with us, because she adopted us and definitely is the one calling the shots).

Why did you start using Python?

TL;DR: I don’t really know, but I certainly don’t regret it.

One fine day in 2006 as I travelled through the interwebs, I serendipitously stumbled over the website of a programming language named after my favourite comedy group. I pretty much inhaled the great Python tutorial in one go. I still remember that vividly – it was love at first sight. Those inbuilt data structures! The simplicity! The clarity of the syntax! No curly braces soup! Next I read a hard-copy of the Python 2 incarnation of Dive into Python by Mark Pilgrim and I was completely captivated by that beautiful language and its possibilities. Thank you Guido and Mark!

While still working in that menial job in the factory without any perspective there, learning that language well and figuring out what to do with it became my goal. I started dreaming of being a professional developer creating software using Python. The problem was that Python was far from having hit the mainstream back then and Python jobs weren’t something very common at all. I was also in my mid thirties already and still pretty much convinced that not being “good at maths” would make this an impossible dream anyway. I somehow had made peace with the idea that I would toil away in one McJob after the other for the rest of my life. My wife though wouldn’t have any of this nonsense and said I wouldn’t know if I didn’t try. She was prepared to support us financially during my studies and I didn’t have any excuse anymore (I told you she is wonderful). I decided to get a proper formal education and we moved to the North, where life is cheap and I enrolled in a small university of applied sciences. The first exam I took was maths. I achieved the second best score in that year … “not good at maths” … Ha! Having been out of school for 15 years, I had to catch up a lot, but I put the work in and earned my degree as one of the best in my year. My first job in tech that I hold until today at Avira consists mainly of creating software in Python with a growing amount of time spent mentoring and teaching (especially around test and build automation). So don’t listen to the naysayers or the pessimistic voices in your head! Follow your dreams, kids 🙂

What other programming languages do you know and which is your favorite?

When I was 15, I got a Commodore 64 for Christmas (because I had badgered my mother for months after having seen a VC-20 at a friends’ house). I learned a bit of programming in BASIC, but typing in all these listings in an archaic text editor on a horrible keyboard wasn’t that much fun, so I mainly played games (Space Taxi!). I also took CS in school (which was still very exotic in the mid 1980s) and learned ELAN on an EUMEL system. That was fun. When I was 17 I came into a small inheritance which I invested in an Atari 1040 ST. That one came with Omikron Basic and a German manual. I read that manual cover to cover and started writing mouse-driven programs with graphical user interfaces for fun. I also used the Atari as a drum computer for the band I had in school (we couldn’t find a real drummer). Turns out that covering Smoke on the Water driven by sterile electronic drum beats wasn’t that popular at the end of the 1980s, but we had fun 🙂

My first band – I am front left. Not in the picture: our “drummer” – an Atari 1040 ST.

That support board I mentioned previously which brought me back to computering 15 years ago is running on a phpBB board and I am still running it today. phpBB is a great board software and PHP 7 with its modern tooling is quite pleasant to develop in nowadays.

In university hardly anyone had heard of Python yet. On the curriculum where C, Java, Assembler, and VHDL. In that time Python was my go to language for writing scripts to help me with my assignments.

I also taught myself AutoHotkey to work around weaknesses of the tools my wife uses in her job as a technical translator. It was pretty useful for quick and dirty automation of tasks in GUI-driven programs that don’t want to be automated.

If I had to pick a favourite, it would have to be VHDL. Not because I have any use for it nowadays (I haven’t), but because being exposed to the language and the learning experience. First off: describing hardware in an ADA inspired language with inbuilt parallelism (because the “compilation” results in actual logic circuits on an FPGA) was an enjoyably different experience that broadened my general outlook on programming. But more importantly: the course was very hands-on and it was the only course, where learning to write automated tests was an integral part the curriculum. In VHDL this is done with testbenches. They provide a a simulated environment for writing black box tests, giving stimuli and asserting on outputs and behaviours of the circuits. This gave me the first tangible experience of how valuable automated tests are in both exploring your design and gaining confidence about the correctness of it. I’d like to thank Prof. Dr.-Ing. Dirk Rabe who brought a lot of real world experience and enthusiasm for his topic into the course which made all the differences.

Still: Python is my favourite by far. Not just because of the language itself, but also because of the included batteries, the ecosystem around it and especially because of the very friendly and inclusive community. Also: Python is the second best language for everything 🙂

What projects are you working on now?

Since the beginning of 2017 I am mainly open source gardening in the tox automation project. For me this means doing releases, issue triaging, automation, coordination and coaching. It takes up a surprisingly large amount of time and energy, but it is also rewarding at times and brings me in contact with a lot of smart and kind humans that can teach this old dog a few new tricks :). I also learn a lot about the ecosystem and good practices in general just by hanging out in the issue trackers of tox and related or upstream projects. I do take frequent breaks though and let the Github notifications pile up without feeling guilty (at least not very). In the tox project there is now a growing second generation community, which I am confident will carry the project into the future. I’d like to thank Holger Krekel for creating these great tools and for nurturing a great community of smart and kind people around them.

pytest sprint 2016

I also generally try to be a good citizen and contribute to a variety of projects, whenever I see the need and am in a position to help. This might come in the form of (hopefully good) bug reports, bug fixes, (documentation) enhancements or participation in design discussions.

I also like to help newcomers getting started with Python and help them to get on a path of self-guided, exploration driven learning. I give hands-on, project driven courses, showing them the tools to explore the language and introducing them into the data and execution model. Besides the usual suspects, there is one great tool I’d like to mention that deserves more attention: Python Tutor by Philip Guo is very good for visualizing language fundamentals and checking your own assumptions. Another great tool for this kind of learning (and obviously developing) is PyCharm. Things like the pydev based visual debugger, excellent static code analysis, intention actions and quick fixes can teach you a lot. There is also PyCharm Edu which uses PyCharm as a vehicle to provide interactive courses in the IDE itself, which I find an interesting concept.

I know, I am going off on a tangent here, but I think it is important to mention that learning to program is not easy and that it takes time. Just like learning to play a musical instrument properly (as opposed to just making some noise :)). It is also not just about learning the language (as in syntax, semantics, data and execution model, etc.) – there is also tooling, libraries, idioms and culture involved and these are quite different for every language you might encounter. I always cringe when I hear someone say that you can learn a new language in a matter of weeks or even days. If you start from zero it takes already a non-trivial amount of time to build up some basic computer literacy before you can start becoming productive as a programmer. For further elaboration on that I’d like to point to Teach Yourself Programming in Ten Years by Peter Norvig.

Which Python libraries are your favorite (core or 3rd party)?

  • Cog by Ned Batchelder will always occupy a special place in my heart. In my bachelor thesis I added an event system to the RTS real-time hypervisor enabling communication between different operating systems running on that hypervisor. It was awfully slow to test because parts of it needed to be initialised during boot and the code was spread out over different modules running in different operating systems. To create a quicker feedback loop, I wrote the code sandboxed in a home grown (Python based) test harness inspired by VHDL testbenches. This enabled me to test the code locally in isolation. I also used Cog to generate parametrized tests similar to what I later found out was similar to what pytest could do (I wish I had learned about it earlier – would have saved me a lot of work :)). To test the code in context I used Cog to inject it into the different modules, to compile and run on a real hypervisor. Cog is one of those “simple” ideas that turn out to be an amazingly powerful and versatile tool.
  • pathlib by Antoine Pitrou finally brought path objects to the stdlib. My first ever talk at a conference was about how much I miss a widely adopted path library we can all agree on, so I am quite happy about that and how it is evolving. As of Python 3.6 the whole stdlib strives to support the file system path protocol (PEP 519).
  • pytest / tox / devpi is my favourite test and release toolchain. Although they are all good tools in their own right. The fact that they all come out of the same community means that they play very well together.
  • pluggy is the library that enables pytest/tox/devpi to support an arbitrary number of independently developed plugins that can be installed alongside those tools to be automatically registered, enhancing/changing the behaviour of those tools.
  • Flask – my favourite web framework – ideal for hacking together dynamic websites and HTTP-based APIs quickly. In combination with a gevent based embedded server you can build surprisingly performant and stable backends running on Windows – if I need something really fast though and don’t have to build it for Windows, I use Falcon.
  • Plumbum Shell Combinators – a bit of a hidden gem. “The motto of the library is ‘Never write shell scripts again’, and thus it attempts to mimic the shell syntax (shell combinators) where it makes sense, while keeping it all pythonic and cross-platform.”
  • Last but not least: the whole stdlib as is a great source of neat tools and concepts and I warmly recommend Doug Hellman’s Python module of the week (PyMOTW 3) as a great addition to the documentation.

What top three things have you learned contributing to open source projects like tox?

  • There is a very friendly global community of Pythonistas creating and maintaining all kinds of great libraries and tools around the core language. Python would not be one of the most popular languages on the planet if this ecosystem would not exist. Sadly many critical projects are lacking resources and “maintainer burnout” is a serious problem that needs to be taken much more seriously and should be addressed on a societal level. See Roads and Bridges: The Unseen Labor Behind Our Digital Infrastructure – Nadia Eghbal
  • For any `n` units of time spent on programming the “business logic” in a given project `n * x` units of time are spent on communication, organisation and process negotiation/automation. `x` is very close to 1 in pet projects but grows when they become popular and it grows even larger if they become an integral part of the language ecosystem.
  • Most people who report issues in the projects I am involved in are friendly, patient and understand that maintainers and contributors don’t owe them anything. If they do not provide very helpful information in their original report and the communication turns out to be less than optimal this is usually not due to malice. It is either due to lack of knowledge and experience in how to approach their problem or coming to the project having to deal with very specific problems not (yet) solved by the project. To take tox as a an example: it abstracts away a lot of pain around packaging and test automation, but when that abstractions break down, many users don’t even know how to analyze the problem, because they just care about their code and not about packaging or the intricacies of a tox testrun. Knowing my way around these things a bit better than the average user, I need to constantly remind myself of that when communicating to make sure, I am being helpful rather than just being annoyed about their lack of skills or patience analyzing the problem. To them tox is something that usually just works and helps them not having to deal with all that. There is also the other end of the spectrum: users being very deep into the topic and having much more experience than me. Requests, criticism and ideas coming from there sometimes baffle me and I sometimes I have to invest a great deal of time to even start understand what they are on about. I had to learn that sometimes it is better to take a step back and let somebody else (or nobody at all) deal with certain issues. I doubt that one single person will ever be able to know and understand everything about the problem space tox lives in, because it is actually staggeringly vast – spanning many usage scenarios, platforms, Python implementations, tricky upstream bugs and very creative configurations.

Are there any neat new things going on when it comes to testing in Python?

Not just specific to Python, but I generally appreciate the ongoing trend to tear down the walls between development, testing and operations. There is always going to be specialisation, but I think the closer those groups of specialists work together, the better the resulting experience is – and I mean that for users as well as creators/operators. I believe that if you apply the same principles and quality standards to testing and operations as to production code, life becomes much more pleasant for everyone involved. Better, more stable, and easier to maintain software is the result (also: happier developers/testers/operators :)).

Also not specific to Python, but a very important aspect of tests is that they need to be run. Ideally after every change. Seems obvious, but is still often not the case or at least not often enough. Badly maintained, slow and flaky test suites which are only run before an upcoming release create a significant amount of friction and pain. When too many changes have been made between two test runs, the cause of new failures might be very hard to determine. If I am being consulted in such a project, my main advice is to improve this situation as the first thing in an effort to make a software better to test and more stable. Everything else should come later. Continuous Integration/Delivery/Deployment in FOSS is an old hat by now – the situation behind many corporate firewalls is still quite different. Someone who wants to learn how this can work for their company can look at established open source projects embracing these principles and go from there. The tox project has helped making this more mainstream in the Python world and also as a project started to embrace this philosophy coming very close to a completely automated release process. In the tox project Gábor Bernát and Anthony Sottile have been very busy recently in this regard. Our test and release process is pretty much fully automated by now. A release is being done by pushing a version tag to master and the rest happens automagically.

And now some things more specific to Python. A few projects in the field of testing and code quality I use myself or deem interesting:

  • hypothesis is a library for creating property-based tests that works nicely together with pytest.
  • black is a relatively new automatic formatter that helps me stop worrying about how to format my code and prevents a lot of stylistic bikeshedding amongst the developers in a team. All you have to do is to cede control.
  • mypy is the reference implementation for checking PEP 484 conform type hinting, enables gradual typing to combine the best of the dynamic and static typing worlds.
  • pre-commit is the tool to bring all your linting, checking and formatting tools together and integrate them in your development and CI workflow.
  • coverage.py – powering pretty much every coverage report for Python code you encounter. I don’t even know any alternatives …
  • And to mention two interesting projects from the up and coming data sciences: pytest-cases and datatest – I have not used them myself yet, but I think they are worth checking out.

What is your motivation for working in open source?

I like that question, but find it a bit hard to answer. It touches on my personal values and also on the way I view society and the trajectory it is on. But let me try: on the one hand I see amazing scientific and technological progress that could free all humans from the burden of having to fight for their survival within the next decades and on the other hand we fail miserably in managing the limited resources of the planet in a sustainable way, effectively destroying the basis of our survival. Our productivity is growing constantly since the beginning of the industrial age and thanks to computering and the automation coming from that, the velocity of that is increasing dramatically. Despite that, social stratification is worsening in most societies for several decades now and wealth is concentrating in ever fewer hands.

I often feel utterly helpless when I look at all this, but I try to play my part in changing its trajectory. I feel that the best way I can do that in my current situation and with my current skill set is to be a good citizen in the global open source community, helping to advance the overall quality of software and the global capacity for process automation in the hope that this will be used for the advancement of society as a whole rather than lining the pockets of a few privileged people. One aspect of which I am growing increasingly aware of is the need for compassion and inclusion. Technology is part of a complex feedback loop involving society and technical feasibility. Technology is not unpolitical and being involved in its creation, I try to be aware of this.

I also believe that information and knowledge should be free and I want to be part of the creation of that without primarily thinking about what material advantages I can gain from that. We are all standing on the shoulders of giants and the idea that one single person made any significant invention or discovery on their own is simply ridiculous to me. Knowledge and power (sometimes being equated anyway) should be distributed as evenly as possible to make sure that a few bad actors can’t spoil it for the rest of us. Democratic processes can be slow and tedious, but – on the level of society – still better than all other models of government we tried. But we have to make sure that those processes aren’t easily corrupted. One hope I have to “corruption proof” society a bit more and bring us all on a more even footing would be the introduction of a universal basic income. Scott Santens is a great person to follow to learn more about this topic.

Thanks for doing the interview, Oliver!

Print Friendly, PDF & Email