EuroPython 2016 remarks

Last week, EuroPython 2016 finished, and it was an amazing conference I had the pleasure to attend. Here is my review of those days.

The conference

I arrived on Saturday noon at Bilbao, Spain, the day before the conference, so I had some time to know the city, see the venues, etc. The next day, on Sunday, was for two separate workshops: Django girls and Beginner's day. I attended the beginner's day as a coach, and helped a group of intermediate developers with several exercises aimed at explaining some Python concepts, such as: context managers, decorators, magic methods, generators, etc. It was really curious that some of these topics were those I was going to cover on my talk on Wednesday, so I felt really glad about that. I took an oath (very funny BTW) for becoming a beginner's mentor, and so I did (it was really good actually). I had a great time helping other developers, exchanging ideas and experiences during lunch, solving problems, and getting a first glimpse on what the conference was going to be like.

Read more...

Upcoming talk at EuroPython 2016

I am glad to inform that I will be speaking at EuroPython 2016 conference.

My submission about clean code in Python was accepted, so in the next edition of EuroPython 2016, in Bilbao, Spain, I will talk about clean code principles for Python. Here is the abstract:

https://ep2016.europython.eu/conference/talks/clean-code-in-python

The full list of talks is available at:

https://ep2016.europython.eu/en/events/sessions/

If you are interested, subscribe to the EuroPython blog and Youtube channel. I will include more details in a separate post.

Read more...

Checking Python files with Vim

Vim is an excellent editor, and mastering it leads to more productivity. Even though is very extensible and allows to be configured by many plug-ins I rather keep it as simple as possible, trying not to use many plug-ins (neither packagers like Vundle, etc.).

However, I do make use of an extension that checks Python files for errors, PEP8, among other things: flake8. Because I do not use plug-in platforms for Vim, I install just this one manually, by making the command flake8 available system-wide1.

Read more...

Do not import *

It is well-known among Python developers (or at least, it should be), that is a bad idea to import everything from a module, for example by doing from <module> import *.

The idea on this post, is to highlight and gather the reasons why this is a bad practice, in order to collectively identify many undesired effects. However, without losing pragmatism, in case there are some odd reasons why this might be acceptable, I will also mention them, if any. Let's see where we get.

Read more...

Writing forward-compatible software in Python

Python 3 is the future of Python. However there might be a problem in the community if both Python 3 and 2 coexist. The former one was great and brilliant, but it is time to start writing software in the new version in order to move towards new features and improvements.

Let's start by the beginning. One of the reasons I always preferred Python over the rest of the programming languages is because it is more advanced, meaning that included many concepts that other languages did not. For example, think of how early Python adopted ideas like lambda functions, dynamic typing, duck typing, context managers, metaclasses and so on, while other technologies (namely Java, C++ for example1) were still using data structures and calling them "objects". Python has always been many steps ahead.

Read more...

Default arguments in Python functions

This post is based on a gist I wrote a while ago, about why is not a good idea to pass default mutable objects as parameters in python function definitions.

While the gist is explained through an example that uses lists, the principle is applicable to all sorts of objects (dictionaries, sets, etc.).

{{ gist(owner=“rmariano” id=“7593536” filename=“function_parameters.md” )}}

If you are an experienced python developer, you probably knew this caveat, nevertheless is something interesting to show to new python developers, and to remember even if you have been writing code in Python for years.

Read more...

On returning consistent data types

This post is inspired on an issue I once found, while I was using a well-known library in Python for parsing YAML files. The problem was that when it was loading the content of the file, the result was not coherent, because sometimes it returned the content as a python dict, but if the file was empty, the return value was None.

Do you notice something odd here?

What if I want to use the result? I cannot do it safely, for example:

Read more...