Blog restyling!

Dear Readers,

it’s been a while since I’ve posted on this blog: I’ve been off to the United Kingdom for months and quite busy.

Now it’s time to go back to the old habits 🙂

… with a few news:

  • from now on, this blog will focus only on travels, life and wellbeing! Some of you may think “wait – but, I remember a lot of technology posts from this blog! Will this mean: no more tech posts on it ?” The answer is: yes, but I’ve created a brand new blog dedicated to technology – it’s called “Vorsprung durch Informatik” and can be found here: http://csparpa.github.io/blog
  • as this blog will mostly be dedicated to travelling, I’ve decided to open it to external contributors. So you will see posts written by people that collaborate with me and share with me a passion for travels and exploration!

Meet the first external contributor: Selena Nuccini, from Parma (Italy). She describes herself as…

A girl who’s full of life and eager to travel.. folks, that’s me: Selena! 🙂 authentic Parmesan, I have a part-time job and study in this wonderful italian city, which nothing on earth will force me to leave. In my spare time I love drawing, writing but most of all travelling… and that’s why you meet me on this blog! 🙂 Thanks to my parents, I’ve been travelling since when I was a child and now that I’ve grown up I don’t want to stop discovering the world.

Stay tuned on the blog for upcoming posts about Selena’s recent travels and my recent UK experience!


Cari Lettori,

è qualche tempo che non posto sul blog: sono stato nel Regno Unito per alcuni mesi e sono stato abbastanza occupato nel mentre.

Ora è giunto il momento di ritornare alle vecchie abitudini 🙂

… con qualche novità:

  • da oggi, questo blog sarà unicamente dedicato ai viaggi, alle esperienze di vita e al wellbeing! Alcuni di voi potrebbero pensare “aspetta un momento – ma io ricordo di aver visto un sacco di post sulla tecnologia su questo blog! Vuol dire che non ci saranno più post tecnologici sul blog ?”  La risposta è: si, ma ho creato un nuovo blog totalmente dedicato alla technologia – il suo nome è “Vorsprung durch Informatik” e lo potete trovare qui: http://csparpa.github.io/blog
  • dal momento che questo blog sarà dedicato soprattutto alle esperienze di viaggio, ho deciso di aprirlo alla collaborazione con persone esterne. Quindi, potrete leggere post scritti da persone che collaborano con me e condividono la mia stessa passione per i viaggi e l’esplorazione!

Vi presento la prima collaboratrice esterna: Selena Nuccini, da Parma (Italia). Di se stessa dice questo…

Una ragazza piena di spirito e con tanta voglia di viaggiare.. esattamente gente, questa sono io, Selena! 🙂 Parmigiana inside, lavoro part time e studio in questa magnifica città italiana, che non ho intenzione di abbandonare per nulla al mondo. Durante il mio tempo libero amo disegnare, scrivere e soprattutto viaggiare… proprio per questo motivo sono qui in effetti! 🙂 Ho imparato a viaggiare fin da piccola grazie ai miei genitori, e ora, anche se sono cresciuta, non voglio abbandonare la mia voglia di scoprire il mondo.

A breve troverete sul blog i post relativi agli ultimi viaggi di Selena e alla mia recente esperienza nel Regno Unito!

The relativity of little green men

This is a photo of Earth and Moon taken from NASA’s Curiosity automated rover exploring the surface of Mars. They turn out to be the two micro-spots in the middle (yes, because they ARE two, didn’t you notice? Wear your glasses…)

Who are now the little green men”? Terrestrians! 🙂

Earth as seen from Mars

Earth as seen from Mars

Meditation on the Zen of Python

Read it

If you have ever programmed anything in Python, you probably used the “import” statement: the modules of the Python standard library  can be imported into your code or into the interpreter. Take a look at the standard library folders and you’ll find the “this.py” module… what is that? Not much a self-explicative name for a Python module, huh? And you – Java lovers – forget about the Java “this” keyword: you’re far afield.

This module is the mystic “Zen of Python”:

import this

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Woohaaaa!!! What?!?! A sort of mantra???

The Pythonic view of the software universe

Kidding apart, the Zen states the high-level development guidelines that were followed in the design of the Python language itself; it was formerly stated into the PEP-20 by Tim Peters, one of the fathers of the language along with Guido Van Rossum (BDFL). Ok, I’m curious about it: I open the this.py code in my favourite text editor and I notice that…

The Zen of Python does not obey the Zen of Python

What??? Here is the source code:

s = """Gur Mra bs Clguba, ol Gvz Crgref

Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf orggre guna pbzcyvpngrq.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
Nygubhtu cenpgvpnyvgl orngf chevgl.
Reebef fubhyq arire cnff fvyragyl.
Hayrff rkcyvpvgyl fvyraprq.
Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.
Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.
Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.
Abj vf orggre guna arire.
Nygubhtu arire vf bsgra orggre guna *evtug* abj.
Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.
Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""

d = {}
for c in (65, 97):
for i in range(26):
d[chr(i+c)] = chr((i+13) % 26 + c)

print "".join([d.get(c, c) for c in s])

The first approach to this code might be bewildering… but it’s not so hard to understand, in the end: basically, you have a huge string containing the whole crypted Zen and then you decode it into readable English characters and print it out loud. A few hints:

  • 65 is the ASCII for ‘A’
  • 97 is the ASCII for ‘a’
  • there are 26 letters in the English alphabet
  • the “d” dictionary turns out to have uppercase/lowercase chars as keys and their corresponding translitterated chars as values. The “crypting magic” is given by: i+13 % 26 + c
  • You have that “A”= decrypt[crypt[“A”]] = crypt[crypt[“A”]]Oddity: the Zen does not follow many of its aphorisms! In fact, its code is far from being explicit, and if it’s true that readability counts, well, the Zen doesn’t shine at it. Ok, practicality beats purity but this is complex (not complicated) to read out; in fact the implementation could be simpler to explain, which conveys that this could be done in a better way.

    A metaphor

    My intention is not to disapprove Tim Peters’s work (never be it! I am just a silly rookie!!!) but to show what I think about the Zen: I think that it is a metaphor. It basically poses a problem to its readers, who need to “decipher” it in order to understand how it really works: this is a strong metaphor of life – if you dig deep on problems/difficulties you come up to be sage about them. And so goes for Python design guidelines.

    … and considering that “now is better than never”…

    … while writing this post, I scribbeld (it was funny!) a revised version of the Zen of Python. It shows a few additional features (get random aphorisms, seek for specified keywords) that can help developers to better read and lookup the original Zen of Python. Features that – hopefully – comply with what the Zen itself says Occhiolino