PyCon.de: an admin’s cornucopia, python is more than just better bash - Christian Theune

Tags: pycon, python

(One of my summaries of a talk at the 2017 PyCon.de conference).

A “cornicopia” is a “horn of plenty”. It keeps on giving.

Pragmatism. I can quickly write some python fast for a task I need to do now. And it will be good enough. You can start right away: you don’t need to start designing an architecture beforehand like you’d have to do in java.

Often if you fix something quickly, you’ll have to fix it a second time a day later. With python, you don’t need to write your code twice. Perhaps 1.5 times. You can add tests, you can fix up the code.

What do they use from python?

  • Language features. Decorators, context managers, fstrings, meta programming.
  • Python’s standard library. You get a lot build-in.
  • Releasing. zc.buildout, pip, virtualenv.
  • Testing. pytest, flake8.
  • Lots of external libraries.

Some of these in detail.

  • Context managers. Safely opening and closing files. They had trouble with some corner cases, so they wrote their own context manager that worked with a temporary file and guaranteed you cannot ever see a half-written file.
  • Decorators. Awesome. For instance for automating lock files. Just a (self-written) @locked on a command line function.
  • asyncio. They use it for starting up various backup jobs at the same time. The overhead you have for getting good async code is very low. yield from is really handy. It is just regular python code, you don’t have to think too hard like with other async solutions.
  • Structlog. An external library for creating structured logs. You can also pass along loggers and add information. This can be handy for seeing what happens during execution.
  • expect/pexpect. You can use it for interacting with command line programs. You call them and “expect” a prompt and interact with it.
  • execnet. “Mobile python”. If you can connect to a remote machine and that machine has python? Then you can send over python modules and pickled data. Basically you’re executing your python code on the other machine.
  • cython. They abuse it for a “setuid” script. In such a script, you cannot use a #!/usr/bin/python line. So they use cython to compile the couple-of-lines python script into an actual binary...

He’s been working with python for 18 years now and he’s constantly surprised by the amount of quality software you can use and that you can rely on for a long time.

https://abload.de/img/screenshot2017-10-05alnu1k.png

Photo explanation: some 1:87 scale figures on my model railway (under construction).

blog comments powered by Disqus
 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):