How I failed to make my first contribution to the Python programming language, and what I learned from it.
Last month I
wrote about how I rewrote
z from scratch after I started using
10 days later I posted the following toot on Mastodon:
There’s a problem with my implementation: ‘recent’ paths only get priority after they’ve been accessed enough times.
There’s an elegant solution for this, let’s see if you can find it!
There’s a clue on my github repo: https://github.com/dmerejkowsky/dotfiles/branches
Answer on my blog soon.
PS: No spoil, please
Well, it’s time for me to give the answer.
z is a tool that will remember all the directories you are visiting when using your terminal, and then make it possible to jump around those directories quickly.
Let’s try and rewrite this functionality from scratch, maybe we’ll learn a few things this way.
TL;DR: Annotations in Python3 are very useful when declaring interfaces
If you want to stop reading here, I’m not going to stop you:)
If not, allow me to take you to on a small journey where I explain what all of this is about …
This is a short post describing how I lint my Python code. You’ll see it’s a bit more than just installing some plug-ins in a IDE, instead it’s a little bit of scripting code.
For quite some time I’ve been adding a file called
ui.py in some
of the Python projects I was working on.
Since I believe in the rule of three and I already have three different projects using it, I’ve decided to share it to the world.
Feel free to take a look at the github page.
For years I’ve been struggling with the
I never could remember how to use it, mixing the order of the parameters, and the man page did not help.
$ man ln SYNOPSYS ln [OPTION]... [-T] TARGET LINK_NAME (1st form) ln [OPTION]... TARGET (2nd form) ln [OPTION]... TARGET... DIRECTORY (3rd form) ln [OPTION]... -t DIRECTORY TARGET... (4th form)
So I thought, why not write a small wrapper around it?
This post is heavily inspired by a presentation I saw at the last Paris.py meetup.
The speaker (Nicolas Mussat, CTO at MeilleursAgent.com), was kind enough to allow me to publish this on my blog.
You can find the original slides (in French) on slideshare.
Say you have a program named
foo that is supposed to be used from the command
line, written in Python.
It provides lots of various features, so you decide to group them into
mercurial does for instance.
So your program can be called in the following ways:
$ foo bar --baz --num-jobs=4 runs bar(baz=True, num_jobs=4) $ foo read file.in --verbose runs read("file.in", verbose=True)
Assuming you are using Python for this, which library should you use to implement command line parsing?
I’ve been using pylint for quite some time now, so today I’d like to share a few tips with you.
Update: Itamar Turner-Trauring also wrote a nice article about pylint, you should read it too: Why Pylint is both useful and unusable, and how you can actually use it
Today I thought I’d share my experience with various test tools for the Python programming language.