Installing Python and virtualenv on MacOS

Posted on Wed 19 December 2018 in Python • Tagged with python, osx, programming, software, development, macos, virtualenv, venv, version, installing, installation, brew, mkvirtualenv, virtualenvwrapper

How to install Python and virtualenv on MacOS

Continue reading

Why I mentor on

Posted on Sun 04 November 2018 in Python • Tagged with python, mentoring, programming, software, development, exercism, student

Exercism ( is a platform that has been created to help people improving their coding skills, thanks to the volunteers mentoring the students. There are tracks for almost all the popular languages and each track has coding tests that the students can download, solve offline using their preferred editor, and test the solution against the provided unit tests. Once the solution is ready to be reviewed (or even if it's not complete but the student needs help), it can be submitted to the website and it will go in a queue where the first available mentor will pick it and start mentoring.

The service is free to use for all the students and the mentors are all volunteers (this doesn't mean that the platform doesn't have any costs. If you are curious about the resources needed to keep the platform alive, you can give a look at this answer on Reddit.

When I found out about the platform, I decided to use it (as student) to improve my Go coding skills. I must say that I've been learning a lot from the mentors and some of them are putting a lot of effort to give you all the possible advices to improve your coding style. In a single exercise once, I learnt at least five things about Go I didn't know before!

I've been a Python developer (professionally) for the last 5 years, but I've never considered myself an "expert". I decided to give it a try with mentoring, because I felt I wanted to give something back to the community, so I registered as mentor too and started mentoring in the Python track.

The first surprise has been that mentoring other students, I was probably learning more than how much I was teaching. First of all, once you already know how to solve a problem, it's always interesting to look at other possible solutions. I've found sometimes that students were providing better (more concise and readable) solutions than mine. Last but not least, before advising someone about conding style or a more idiomatic solution, I always double check things from different sources. There is nothing wrong making mistakes, especially if you are learning... but it would be damaging for the student if I was teaching them something wrong, so I need to be sure about what I say. This of course makes me study, even the basic things, again and again and at the end of the day, my skills are better too.

Once you join the mentors group, you are invited to a private Slack where you can count on the help of other mentors (we have channels for each track/language) or ask questions. So, if you are not sure about something, you can always ask around.

If my story and experience convinced you, Exercism is looking for more mentors! The more we have available, the less time the students have to wait in a queue to be mentored. You can find all the instructions at this address

Using ipdb with Python 3.7.x breakpoint

Posted on Tue 16 October 2018 in Python • Tagged with python, debugging, programming, software, development

Python 3.7.x introduced a new method to insert a breakpoint in the code. Before Python 3.7.x to insert a debugging point we had to write import pdb; pdb.set_trace() which honestly I could never remember (and I also created a snippet on VS Code to auto complete it).

Now you can just write breakpoint() that's it!

Now... the only problem is that by default that command will use pdb which is not exactly the best debugger you can have. I usually use ipdb but there wasn't an intuitive way of using it... and no, just installing it in your virtual environment, it won't be used by default.

How to use it then? It's very simple. The new debugging command will read an environment variable named PYTHONBREAKPOINT. If you set it properly, you will be able to use ipdb instead of pdb.

export PYTHONBREAKPOINT=ipdb.set_trace

At this point, any time you use breakpoint() in your code, ipdb will be used instead of pdb.


Go: defining methods on struct types

Posted on Mon 16 March 2015 in Go • Tagged with go, golang, programming, struct

In Go it's possible to define methods on struct types. The syntax needed for it can be a bit strange for people that are used to define classes and methods in Java, C# etc... but once you learn it it's quite easy to use.

In my case for example I needed something that could contain a Timer object, a string and a method that could start the timer and call a method at the end of the Timer execution. I implemented it in this way:

type DeviceTimer struct {
    DeviceID    string
    DeviceTimer *time.Timer

func (timer DeviceTimer) startTimer() {

The key point is row 6 func (timer DeviceTimer) startTimer() { ... } where I defined a method called startTimer and I specify timer DeviceTimer inside the func definition. This basically "extends" the struct DeviceTimer adding that method to it. This means that I can call that method in this way:

timer := time.NewTimer(time.Millisecond * 300)
device_timer := DeviceTimer{"abc123", timer}
go device_timer.startTimer()

This is all you need to do. If you want to read more about this subject, I can suggest to read these two articles:

Note: I'm not a Go expert and these are just my personal notes I'm taking during my learning experience. I'm very keen to share my notes with everyone, but please don't take them as notes from an expert Go developer.