Planet Python

Syndicate content
Planet Python -
Updated: 5 hours 11 min ago

Andre Roberge: Easily modifiable Python

Mon, 2017-04-24 18:47
You want to try out some new syntactic construction in Python but do NOT want to have to go through the trouble of 1. modifying Python's grammar file 2. modifying Python's lexer 3. modifying Python's parser 4. modifying Python's compiler 5. re-compile all the sources  so as to create a new Python interpreter? (These steps are described in these two blog  posts.) It can be done much more easily
Categories: FLOSS Project Planets

François Dion: Meet Eliza #AI

Mon, 2017-04-24 17:48

I will be presenting and directing a discussion on artificial intelligence, from various angles including the arts, Tuesday April 25th at Wake Forest in Winston Salem, NC.

Details here:

Francois Dion
Categories: FLOSS Project Planets

NumFOCUS: Moore Foundation gives grant to support NumFOCUS Diversity & Inclusion in Scientific Computing initiatives

Mon, 2017-04-24 15:23
As part of our mission to support and promote better science through support of the open source scientific software community, NumFOCUS champions technical progress through diversity. NumFOCUS recognizes that the open source data science community is currently highly homogenous. We believe that diverse contributors and community members produce better science and better projects. NumFOCUS strives […]
Categories: FLOSS Project Planets

Weekly Python Chat: Python Oddities

Mon, 2017-04-24 13:15

I tweeted one Python oddity each week in 2016. Let's chat about them.

Categories: FLOSS Project Planets

Ned Batchelder: Shell = Maybe

Mon, 2017-04-24 11:38

A common help Python question: how do I get Python to run this complicated command line program? Often, the answer involves details of how shells work. I tried my hand at explaining it what a shell does, why you want to avoid them, how to avoid them from Python, and why you might want to use one: Shell = Maybe.

Categories: FLOSS Project Planets

NumFOCUS: Anyone Can Do Astronomy with Python and Open Data

Mon, 2017-04-24 11:00
Ole Moeller-Nilsson, CTO at Pivigo, was kind enough to share his insights on how a beginner can easily get started exploring astronomy using Python. This blog post grew out of a presentation he gave at PyData London meetup on March 7th. Python is a great language for science, and specifically for astronomy. The various packages […]
Categories: FLOSS Project Planets

Doug Hellmann: zlib — GNU zlib Compression — PyMOTW 3

Mon, 2017-04-24 09:00
The zlib module provides a lower-level interface to many of the functions in the zlib compression library from the GNU project. Read more… This post is part of the Python Module of the Week series for Python 3. See for more articles from the series.
Categories: FLOSS Project Planets

Mike Driscoll: PyDev of the Week: Honza Král

Mon, 2017-04-24 08:30

This week we welcome Honza Král (@HonzaKral) as our PyDev of the Week! Honza is one of the core developers of the Django web framework. He is also the maintainer of the official Python client to Elasticsearch. You can see some of the projects he is interested in or working on over at Github. Let’s spend some time getting to know Honza better!

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

I grew up in the Old Town of Prague, Czech Republic where I also went to school, including University where I studied computer science (which I didn’t finish). During my studies I discovered Python and immediately fell in love, first with the language and later, after going to my first Pycon in 2008, with the community.

I became a part of the Django community which was (and still is to this day) very welcoming. I became a part of it to learn and, hopefully, contribute something back. For my part it worked amazingly well – I got all my recent jobs through the community and even met my fiancee at a EuroPython conference!

Nowadays I work for Elastic, the company behind Elasticsearch where I do consulting – traveling around the world helping people be successful with open source – and also maintain the official Python client.

Why did you start using Python / Django?

I started in university for a project. I had my eye on Python for some time then and a perfect opportunity presented itself to use it for one of our team projects – we decided it would be a web-based application and Django was the shiny new thing that caught my attention. I introduced it to the rest of the team and have been using it ever since.

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

My other favorite, besides Python of course :), would be shell – I still enjoy writing both simple (or a bit more complex) one-liners as well as longer scripts in shell. I like the variety of it where you have so many possibilities on how to accomplish things with a seemingly limited language. I like how it’s very unlike other languages I am used to working in as it forces you to think more in terms of pipelines and “just” passing off problems to another app/language. It definitely helped my Python skills as well I think – thinking of what I need to keep in a list/variable vs where a simple generator would suffice (as would a pipeline in shell) etc.

Right now I am looking at rust and hoping that a suitable project will come along for me to give it a serious try.

What projects are you working on now?

Currently I am working on elasticsearch-dsl which is an ORM-like abstraction on top of elasticsearch. It is an ambitious project since I wanted to expose all the power of elasticsearch’s query DSL while also trying to make it more accessible to non-experts and generally friendlier. While I think that in some areas I might have achieved this, I still have a long way to go in others; and for some I don’t even see the clear path of what needs to happen which makes it interesting – gives me something to ponder

Categories: FLOSS Project Planets

Import Python: Import Python Weekly Issue 122 - Django ORM vs SQLAlchemy, Type annotation, websockets and more

Mon, 2017-04-24 08:11
Worthy Read
Django ORM vs SQLAlchemy – Vizbi Recently I started using SQLAlchemy and am very impressed with it. I have used Django ORM a lot in the past. This post compares achieving same result using Django and with SQLAlchemy. Let’s see which looks more intuitive.
django, SQLAlchemy, ORM
Know when and why code breaks Users finding bugs? Searching logs for errors? Find + fix broken code fast! You can find the Python integration here -
Python Type Annotation with Graph Algorithms. Part II (Classes) In this part, we will implement graph data structure using classes and interfaces, and discuss when it’s worth overruling type hints.
type annotation, graph
Speeding up Websockets 60X I recently I had the opportunity to speed up some Websocket code that was a major bottleneck. The final solution was 60X (!) faster than the first pass, and an interesting exercise in optimizing inner loops.
Graph Databases: Talking about your Data Relationships with Python This trouble to visualise the relationship between entities in a Relational Database is a great reason to introduce the concept of graph. Graph is a data structure formed by a set of vertices V and a set of edges E. It can be represented graphically (where the vertices are shown as circles and edges are shown as lines) or mathematically in the form G = (V, E).
graph databases
Modifying the Python language in 6 minutes This week I raised my first pull-request to the CPython core project, which was declined :-( but as to not completely waste my time I’m writing my findings on how CPython works and show you how easy it is to modify the Python syntax.
core-python, cpython
Realtime Web Apps with Nginx Nchan and Python Nchan makes writing realtime web based pub/sub applications a breeze. In this article, we will build a simple systems monitoring dashboard which displays process information in realtime similar to what you would see when you run the unix top or htop commands.
nginx, nchan
Intersection of Non-Empty Sets in Python Suppose you generate several sets on the fly, and you want to find the elements that are in all the sets. That's easy, it's the intersection of sets.
list, set, code_snippets
Monitoring Directories for File Changes using Watchdog I was working recently on writing Python code using TDD. So every time I change code I wanted to run command that will test my code if it pass unit tests. In order to do that I needed some service/app that will monitor for file changes, and if it changes execute my batch file that runs unit tests.
python, watchdog
Find Top Developers We help companies like Airbnb, Pfizer, and Artsy find great developers. Let us find your next great hire. Get started today.
Jupyter Notebook in project’s virtual env jupyter
AWS Lambda now supports 3.6 aws, lamda
SQL Server 2017: Advanced Analytics with Python In this session you will learn how SQL Server 2017 takes in-database analytics to the next level with support for both Python and R; delivering unparalleled scalability and speed with new deep learning algorithms built in.
Control-C handling in Python and Trio core-python
Kubernetes Scheduling in Python kubernetes
Learn a Python script for automating the process of publishing podcasts podcast

algorithms: - 2112 Stars, 174 Fork Minimal examples of data structures and algorithms in Python
jokekappa - 74 Stars, 7 Fork A library for delivering one-line programming jokes
cashier - 53 Stars, 2 Fork Persistent caching for python functions
crickbuzz_cricket_score - 13 Stars, 2 Fork A Terminal based program to follow live cricket score by scraping
MigrateGitlabToGogs - 3 Stars, 0 Fork Migrate repositories from Gitlab to Gogs or Gitea
venvdetect - 3 Stars, 1 Fork Detect available Python virtual environments in your current directory
Categories: FLOSS Project Planets

Django Weekly: Django Weekly 35 - Signals, Django Rest Framework, Djangocon 2017

Mon, 2017-04-24 08:09
Worthy Read
Understanding Django signalsIn many cases when there is a modification in a model’s instance we need execute some action. Django provides us an elegant way to handle with these situations. The signals are utilities that allow us to associate events with actions. We can develop a function that will run when a signal calls it.
Know when and why code breaksUsers finding bugs? Searching logs for errors? Find + fix broken code fast!. You can find the Python integration here -
Getting Started with Django Rest FrameworkSort of a learning path made up of curated articles.
Estimated counts for faster Django Admin change_listOne of our tables grew to over 25 million rows. Which, while not a large number, makes the most frequent queries slow. A direct effect it had was on our Admin panel. The change_list form for the model started taking ages to load.
DjangoCon 2017I love DjangoCon. I've been going to it almost every year since I arrived in Europe back in 2010. Sure, a considerable portion of my career has been based on Django, but it's more than that: the community is stuffed full of amazing people who genuinely want us all to succeed and that just makes the conference all the more exciting.
Find Top DevelopersWe help companies like Airbnb, Pfizer, and Artsy find great developers. Let us find your next great hire. Get started today.
Setting up Python 3, Django and Gunicorn on Ubuntu 16.04 LTSinstallation
DjangoCon US 2017DjangoCon US is a six-day international conference for the community by the community, held each year in North America, about the Django web framework. Early bird tickets avialable.
django, djangocon

django-webpacker - 18 Stars, 1 ForkA django compressor tool that bundles css, js files to a single css, js file with webpack and updates your html files with respective css, js file path.
django-starter-kit - 12 Stars, 0 ForkOpinionated template for Django projects on Python 3 and PostgreSQL.
mnm - 9 Stars, 0 ForkMastodon Network Monitoring: track and display browsable stats about Mastodon network (instances, toots, users...).
django-multicore - 4 Stars, 0 ForkA framework that makes it easy to parallelize Django code
django-freeradio - 4 Stars, 4 ForkA Django project for managing a radio station for a community radio station. The code was originally based on the Django website for Brum Radio, and was open sourced as part of a sprint session at DjangoCon Europe 2017.
django-confirmation-mixin - 3 Stars, 0 ForkDjango ConfirmationMixin for CreateView and UpdateView
Categories: FLOSS Project Planets PyDDF Python Spring Sprint 2017

Mon, 2017-04-24 07:00

The following text is in German, since we're announcing a Python sprint in Düsseldorf, Germany.


PyDDF Python Frühlings-Sprint 2017 in

Samstag, 06.05.2017, 10:00-18:00 Uhr
Sonntag, 07.05.2017, 10:00-18:00 Uhr

trivago GmbH,  Karl-Arnold-Platz 1A,  40474 Düsseldorf

Informationen Das Python Meeting Düsseldorf (PyDDF) veranstaltet mit freundlicher Unterstützung der trivago GmbH ein Python Sprint Wochenende im Mai.

Der Sprint findet am Wochenende 6./7.5.2017 in der trivago Niederlassung am Karl-Arnold-Platz 1A statt (nicht am Bennigsen-Platz 1). Folgende Themengebiete haben wir als Anregung angedacht:
  • Openpyxl
Openpyxl ist eine Python Bibliothek, mit der man Excel 2010+ Dateien lesen und schreiben kann.

Charlie Clark ist Co-Maintainer des Pakets.
  • Telegram-Bot

Telegram ist eine Chat-Anwendung, die von vielen Nutzern verwendet wird. Telegram unterstützt das Registrieren von sogenannten Bots - kleinen Programmen, die man vom Chat aus ansteuern kann, um z.B. Informationen zu bekommen.

Im Sprint wollen wir versuchen, einen Telegram-Bot in Python zu schreiben.

  • Jython (Python in Java implementiert)

    Stefan Richthofer, einer der Jython Core Entwickler, wird anwesend sein und über ein Jython Thema sprinten, z.B.

    Using Jython:
    - Jython basics
    - Python/Java integration
    - GUI mit JavaFX in Python

    Developing Jython:
    - Jython internals
    - Bugfixes in Jython core - Können wir ein paar echte Bugs beheben?

    Experimentelles (Was ist schon implementiert? Wir probieren es aus!):
    - JyNI
    - Jython 3
Natürlich kann jeder Teilnehmer weitere Themen vorschlagen, z.B.
  • RaspberryPi-Robot (einen Roboter mit einem Raspi ansteuern)
  • u.a.
Anmeldung und weitere Infos

Alles weitere und die Anmeldung findet Ihr auf der Sprint Seite:

Teilnehmer sollten sich zudem auf der PyDDF Liste anmelden, da wir uns dort koordinieren:
Über das Python Meeting Düsseldorf

Das Python Meeting Düsseldorf ist eine regelmäßige Veranstaltung in Düsseldorf, die sich an Python Begeisterte aus der Region wendet.

Einen guten Überblick über die Vorträge bietet unser PyDDF YouTube-Kanal, auf dem wir Videos der Vorträge nach den Meetings veröffentlichen.

Veranstaltet wird das Meeting von der GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting & Research, Düsseldorf.

Viel Spaß !

Marc-Andre Lemburg,

Categories: FLOSS Project Planets

EuroPython: EuroPython 2017: How you can sponsor us

Mon, 2017-04-24 04:54

Check out our brand new brochure with all details about our sponsor packages, options and lounge events, available on our website.

Sponsoring EuroPython guarantees you highly targeted visibility and the opportunity to present yourself and your company in a professional and innovative environment. 

With more than 1200 participants, 8 days conference program, international keynotes, more than 200 talks, training sessions for beginners, advanced and experts, EuroPython creates an excellent environment to look for new job-opportunities, recruit people, connect, share and learn. 

New Attractive Location for 2017

This year we move to the Palacongressi in Rimini, the largest convention centre in Italy, unique in its design and technology, with 11,000 m² exhibit space, in addition to 39 conference rooms. Check out EuroPython demographics, refresh your mind with our beautiful location and consult the different opportunities we have created for you

Available Sponsor Options

We offer 7 different sponsor packages, with different levels of engagement.

Would you rather have more flexibility? You can separately book special events and choose from a list of very prominent advertisement options: have a table in the training session or get your logo to be by the ice-cream stall; sponsor our laser-tag and party events. 

Do you have further ideas? We can help you develop a tailored sponsorship package that fits your specific targets. If you would like to engage and sponsor EuroPython 2017, please contact us by e-mail.

Don’t miss the chance to become part of the largest Python conference in Europe!


EuroPython 2017 Team

Categories: FLOSS Project Planets

PythonClub - A Brazilian collaborative blog about Python: Configurando OpenShift com Python 3.5 + Flask + Gunicorn

Sun, 2017-04-23 19:37

Configurando OpenShift com Python 3.5


O OpenShift é uma plataforma de PasS que possibilita aos desenvolvedores "subir" aplicações na nuvem de uma maneira simples e rápida. Ele funciona a partir de gears(engrenagens) que representam máquinas que irão rodar as aplicações. Dentro de cada gear é possível instalar serviços, os são chamados de "cartridges".

Existem 3 planos:

  • Online (gratuito, com três gears)
  • Enterprise (pago com suporte)
  • Origin (versão da comunidade e pode ser utilizado livremente)

Um problema que me deparei ao utilizar o Openshift é que ele não possui um cartridge com Python3.5. Porém existe uma forma um pouco mais complicada de resolver esse problema.

Após fazer seu cadastro no OpenShift e instalar o client tools que contém as ferramentas necessárias para configurar nossa aplicação.

Após tudo isso vamos colocar a mão na massa, abra seu terminal e vamos lá.

Criando a aplicação rhc app create <app-name> diy-0.1

Substituindo "<app-name>" pelo nome de sua aplicação. O arquivo manifest.yml criado por Changaco(github) e "forkeado" por Grief(github) contém as configurações de um cartridge customizado que contém o python 3.5.

Para os curiosos o conteúdo do arquivo

--- Name: python Cartridge-Short-Name: PYTHON Display-Name: Only Python Description: 'An embedded cartridge that provides only python, nothing else.' Version: '3.5.0' Versions: ['3.5.0', '2.7.11'] License: The Python License License-Url: Vendor: Cartridge-Version: 0.0.2 Cartridge-Vendor: praisebetoscience Categories: - service - python - embedded Website: Help-Topics: Developer Center: Provides: - python Publishes: Subscribes: set-env: Type: ENV:* Required: false set-doc-url: Type: STRING:urlpath Required: false Scaling: Min: 1 Max: -1 Version-Overrides: '2.7.11': Display-Name: Python 2.7 License: The Python License, version 2.7 Provides: - python-2.7 - python - python(version) = 2.7 '3.5.0': Display-Name: Python 3.5 License: The Python License, version 3.5 Provides: - python-3.5 - python - python(version) = 3.5

Após isso sua aplicação já estárá executando, caso deseje acessar o endereço da mesma deverá ser http://<app-name> Você verá que a página do seu projeto não é nada mais do que o diy (Dot It Yourself), que é uma aplicação Ruby de exemplo que você pode alterar, e é o que vamos fazer.

Se você acessar o diretório do seu projeto verá que existe um diretório ".openshift", dentro desse diretório existe um outro diretório chamado "action_hooks", e dentro desse diretório existem dois arquivos "start" e "stop".

  • "<app-name>/.openshift/action_hooks/start"
  • "<app-name>/.openshift/action_hooks/stop"

Os dois arquivos são respectivamente os comandos para "subir" e "pausar" sua aplicação.


Vamos criar um projeto de exemplo, bem simples, que apenas nos retorne a versão do python utilizada. Primeiramente vamos criar nosso requirements.txt, com gunicorn e o flask.


gunicorn flask

Depois disso vamos criar o arquivo que conterá nossa aplicação.


import sys from flask import Flask app = Flask(__name__) @app.route('/') def index(): return sys.version

Após isso basta fazer o commit de suas alterações.

shell git add . git commit -am 'Minhas alterações'

Após isso você verá que sua aplicação não está rodando, pois ainda não alteramos os arquivos "start" e "stop".

Configurando o Gunicorn no Start e Stop

O projeto diy do openshift nos deixa uma variável de ambiente $OPENSHIFT_DIY_IP com o IP da máquina, dessa forma podemos passar a variável e porta ao gunicorn.


#!/bin/bash nohup $HOME/python/usr/bin/pip3 install -r $OPENSHIFT_REPO_DIR/requirements.txt cd $OPENSHIFT_REPO_DIR nohup $HOME/python/usr/bin/gunicorn app:app --bind=$OPENSHIFT_DIY_IP:8080 |& /usr/bin/logshifter -tag diy &

A primeira linha é o Shebang, o que significa que esse arquivo será executado pelo bash. Na segunda linha vemos nohup, que executa os comandos em uma sessão separada, vemos logo apóes vemos o uma chamada ao pip para instalar nossas dependências. Na terceira linha vemos o nohup, e depois o gunicorn inicializa nossa aplicação flask.

Isso só funciona pois o cartridge customizado instala o python3.5 dentro da pasta home do servidor do openshift.


#!/bin/bash source $OPENSHIFT_CARTRIDGE_SDK_BASH # The logic to stop your application should be put in this script. if [ -z "$(ps -ef | grep gunicorn | grep -v grep)" ] then client_result "Application is already stopped" else kill `ps -ef | grep gunicorn | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1 fi

Podemos ver que o comando ps procura algum processo do gunicorn, caso ele exista o kill será chamado.

Após isso, é só fazer o commit das alterações e você verá sua aplicação rodando.

Espero que o post ajude a quem quer subir alguma aplicação com python3.5 e só tem o heroku como opção.

Categories: FLOSS Project Planets

Evennia: The luxury of a creative community

Sun, 2017-04-23 19:10
For this blog post I want to focus on the series of very nice pull requests coming in from a growing cadre of contributors over the last few months.

Contributed goodness

People have put in a lot of good work to boost Evennia, both by improving existing things and by adding new features. Thanks a lot everyone (below is just a small selection)!
  •  Contrib: Turn-based combat system - this is a full, if intentionally bare-bones implementation of a combat system, meant as a template to put in your particular game system into.
  • Contrib: Clothing sytem - a roleplaying mechanic where a character can 'wear' items and have this show in their descriptions. Worn items can also be layered to hide that underneath. Had plenty of opportunities for extensions to a given game.
  • Contrib: An 'event' system is in the works, for allowing privileged builders to add dynamic code to objects that fires when particular events happen. The PR is not yet merged but promises the oft pondered feature of in-game coding without using softcode (and notably also without the security of softcode!). 
  • A lot of PRs, especially from one user, dealt with cleanup and adherence to PEP8 as well as fixing the 'alerts' given by LGTM on our code (LGTM is by the way a pretty nifty service, they parse the code from the github repo without actually running it and try to find problems. Abiding by their advice results is cleaner code and it also found some actual edge-case bugs here and there not covered by unit tests. The joint effort has brought us down from some 600+ alerts to somewhere around 90 - the remaining ones are alerts which I don't agree with or which are not important enough to spend effort on). 
  • The help mechanics of Evennia were improved by splitting up the default help command into smaller parts, making it easier to inject some changes to your help system without completely replacing the default one. 
  • Evennia's Xterm256 implementation was not correctly including the additional greyscale colors, those were added with new tags |=a ... |=z.
  • Evennia has the ability to relay data to external services through 'bots'. An example of this is the IRC bot, which is a sort of 'player' that sits in an in-game channel and connects that to a counterpart-bot sitting in a remote IRC channel. It allows for direct game-IRC communication, something enjoyed by people in the Evennia demo for many years now. The way the bot was defined used to be pretty hard-coded though. A crafty contributor changed that though, but incorporating the bot mechanism into Evennia's normal message flow. This allows for adding new types of bots or extending existing ones without having to modify Evennia's core. There is already an alternative IRC bot out there that represents everyone in the IRC room as a room full of people in the MUD. 
  • Evennia's Attributes is a database table connected to other objects via a ForeignKey relation. This relation is cached on the object. A user however found that for certain implementations, such as using Attributes for large coordinate systems, non-matches (that is failed Attribute lookups on the object) can also be cached and leads to dramatic speed increases for those particular use cases. A PR followed. You live and learn.
  • Another contributor helped improve the EvEditor (Evennia's VIM-like in-game text editor) by giving it a code-mode for editing Python code in-game with auto-indents and code execution. Jump into the code mode with the command @py/edit.
  • Time scheduling is another feature that has been discussed now and then and has now been added through a PR. This means that rather than specifying 'Do this in 400 seconds' you can say 'do this at 12AM, in-game time'. The core system works with the real-world time units. If you want 10 hours to a day or two weeks to a month the same contributor also made an optional calendar contrib for that!
  • A new 'whisper' command was added to the Default cmdset. It's an in-game command for whispering to someone in the same room without other people hearing it. This is a nice thing to have considering Evennia is out-of-the-box pretty much offering the features of a 'talker' type of game.
  • Lots of bug fixes big and small!
  • Some at_* hooks were added, such as at_give(giver, getter). This allows for finer control of the give process without handling all the logics at the command level. There are others hooks in the works but those will not be added until in Evennia 0.7. 
About that Evennia 0.7 ...

So while PRs are popping up left and right in master I've been working in the devel branch towards what will be the Evennia 0.7 release. The branch is not ready for public consumption and testing yet But tentatively it's about halfway there as I am slowly progressing through the tickets. Most of the upcoming features were covered in the previous blog post so I'll leave it at that.

I just want to end by saying that it's a very luxurious (and awesome) feeling for me to see master-branch Evennia expand with lots of new stuff "without me" so to speak. The power of Open Source indeed!

Image from, released as public domain.
Categories: FLOSS Project Planets

PyBites: Code Challenge 16 - Query Your Favorite API

Sun, 2017-04-23 18:01

Hi Pythonistas, a new week, a new 'bite' of Python coding! This week we'll let you play with Web APIs. They are fun to fiddle with and great for learning and building cool things. Enjoy!

Categories: FLOSS Project Planets

PyBites: Twitter digest 2017 week 16

Sun, 2017-04-23 14:04

Every weekend we share a curated list of 15 cool things (mostly Python) that we found / tweeted throughout the week.

Categories: FLOSS Project Planets Intuitive Explanation of OFDM

Sun, 2017-04-23 08:00
An intuitive explanation on how OFDM works

This article is about the fundamental principle of OFDM. Without going into the mathematical details, I'm going to explain, why the commonly used OFDM waveform is designed as it is. In a previous article, we have already shown a source code example of OFDM.

Let us start with the assumption that we face a static multipath channel (static means, the channel coefficients do not change over all times, i.e. it is time-invariant). Such a channel is a linear, time-invariant (LTI) system, and hence it is described solely by its impulse response h(t). The output signal y(t) of this system is the convolution of the input signal x(t) with the impulse response h(t):

Eigenfunctions of the time-invariant channel

The most important property of LTI systems is, that complex exponentials of any frequency are eigenfunctions of the system. Literally, if the input to an LTI system is a complex exponential, its output will be a complex exponential of the same frequency, but with a different amplitude. Let's verify ...

Categories: FLOSS Project Planets

Will McGugan: PyFilesystem 2.0.3 Released

Sat, 2017-04-22 13:56

I've just released version 2.0.3 of PyFilesystem.

PyFilesystem is an abstraction layer for filesystems (or anything that resembles a filesystem). See this post for more details.

New in this version is a TarFS filesystem contributed by Martin Larralde, which compliments ZipFS nicely.

Contributed by gpcimino, the copy module was extended new functionality to selectively copy only new files from one filesystem to another. Very useful for backups.

This is in addition to bugfixes, and improved documentation.

Categories: FLOSS Project Planets

Roberto Alsina: How I Learned to Stop Worrying and Love JSON Schema

Sat, 2017-04-22 11:32

This post operates on a few shared assumptions. So, we need to explicitly state them, or otherwise you will read things that are more or less rational but they will appear to be garbage.

  • APIs are good
  • Many APIs are web APIs
  • Many web APIs consume and produce JSON
  • JSON is good
  • JSON is better if you know what will be in it

So, JSON Schema is a way to increase the number of times in your life that JSON is better in that way, therefore making you happier.

So, let's do a quick intro on JSON Schema. You can always read a much longer and surely better one from which I stole most examples at Understanding JSON Schema. later (or right now, it's your time, lady, I am not the boss of you).


So, a JSON Schema describes your data. Here is the simplest schema, that matches anything:

{ }

Scary, uh? Here's a more restrictive one:

{ "type": "string" }

That means "a thing, which is a string." So this is valid: "foo" and this isn't 42 Usually, on APIs you exchange JSON objects (dictionaries for you pythonistas), so this is more like you will see in real life:

{ "type": "object", "properties": { "street_address": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" } }, "required": ["street_address", "city", "state"] }

That means "it's an object", that has inside it "street_address", "city" and "state", and they are all required.

Let's suppose that's all we need to know about schemas. Again, before you actually use them in anger you need to go and read Understanding JSON Schema. for now just assume there is a thing called a JSON Schema, and that it can be used to define what your data is supposed to look like, and that it's defined something like we saw here, in JSON. Cool?

Using schemas

Of course schemas are useless if you don't use them. You will use them as part of the "contract" your API promises to fulfill. So, now you need to validate things against it. For that, in python, we can use jsonschema

It's pretty simple! Here is a "full" example.

import jsonschema schema = { "type": "object", "properties": { "street_address": {"type": "string"}, "city": {"type": "string"}, "state": {"type": "string"}, }, "required": ["street_address", "city", "state"] } jsonschema.validate({ "street_address": "foo", "city": "bar", "state": "foobar" }, schema)

If the data doesn't validate, jsonchema will raise an exception, like this:

>>> jsonschema.validate({ ... "street_address": "foo", ... "city": "bar", ... }, schema) Traceback (most recent call last): File "<stdin>", line 4, in <module> File "jsonschema/", line 541, in validate cls(schema, *args, **kwargs).validate(instance) File "jsonschema/", line 130, in validate raise error jsonschema.exceptions.ValidationError: 'state' is a required property Failed validating 'required' in schema: {'properties': {'city': {'type': 'string'}, 'state': {'type': 'string'}, 'street_address': {'type': 'string'}}, 'required': ['street_address', 'city', 'state'], 'type': 'object'} On instance: {'city': 'bar', 'street_address': 'foo'}

Hey, that is a pretty nice description of what is wrong with that data. That is how you use a JSON schema. Now, where would you use it?

Getting value out of schemas

Schemas are useless if not used. They are worthless if you don't get value out of using them.

These are some ways they add value to your code:

  • You can use them in your web app endpoint, to validate things.
  • You can use them in your client code, to validate you are not sending garbage.
  • You can use a fuzzer to feed data that is technically valid to your endpoint, and make sure things don't explode in interesting ways.

But here is the most value you can extract of JSON schemas:

You can discuss the contract between components in unambiguous terms and enforce the contract once it's in place.

We are devs. We discuss via branches, and comments in code review. JSON Schema turns a vague argument about documentation into a fact-based discussion of data. And we are much, much better at doing the latter than we are at doing the former. Discuss the contracts.

Since the document describing (this part of) the contract is actually used as part of the API definitions in the code, that means the document can never be left behind. Every change in the code that changes the contract is obvious and requires an explicit renegotiation. You can't break API by accident, and you can't break API and hope nobody will notice. Enforce the contracts.

Finally, you can version the contract. Use that along with API versioning and voilá, you know how to manage change! Version your contracts.

  • Discuss your contracts
  • Enforce your contracts
  • Version your contracts

So now you can stop worrying and love JSON Schema as well.

Categories: FLOSS Project Planets