Other articles

  1. Using ipdb with Python 3.7.x breakpoint

    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.

    References

    • https://hackernoon.com/python-3-7s-new-builtin-breakpoint-a-quick-tour-4f1aebc444c
    read more

    comments

  2. Soma.fm + Spotify + import.io + Python mashup: automatically create a Spotify playlist with Soma.fm tracks

    I'm a big fan of Soma.fm (a 25+ channels streaming radio based in San Francisco) and during the years I've been writing clients for this radio for different mobile platforms (Maemo, MeeGo, Harmattan, Windows Phone, BlackBerry 10, Jolla). I love in particular their "Indie Pop Rock" channel that during these years made me discover some very good artists.

    When Spotify finally was available in Italy (I'm still using it right now that I live in the UK), something that I always missed was a radio with the same good music. Why not just listening to Soma.fm? Because I like to listen to the music while I commute and in the London Underground it's nearly impossible to have signal.

    So I was thinking: it would be nice to have a Spotify playlist with Soma.fm tracks. Wait a moment.... I can do it!

    Frankenstein_Jr_Mel_Brooks_1974{.aligncenter .size-full .wp-image-981 width="542" height="422"}

    Soma.fm publishes the tracks history with all the tracks streamed during the last hour http://somafm.com/indiepop/songhistory.html so I just needed something to parse this list for me and return me a well formatted version.

    Thanks to import.io (it's a service that takes a web page as input, parse the data and generates a RESTful API to access this data) I was able to easily get the data I needed. At this point I only needed to be able to loop through the list, search each track on Spotify and add it to my playlist.

    The source code is fully available here https://github.com/andreagrandi/spotisoma

    Note: you can't just get the code and run it. You will need to get your own import.io api key, generate your import.io api url, get a Spotify application key (the old/deprecated one, since it was nearly impossible for me to use oauth in a simple Python script due to the fact I didn't have an endpoint to receive the token back. You can get more informations here: https://pyspotify.mopidy.com/en/latest/quickstart/#application-keys) and set your env variables with your Spotify username and password. Last but not least: the old Spotify library only works with Premium accounts.

    read more

    comments

  3. PyngFM: Python implementation of Ping.fm API

    Thu 02 April 2009 | in Python

    ping.fm{.alignright .size-full .wp-image-257 width="99" height="97"}I've just released PyngFM, a Python implementation of Ping.fm API. Ping.fm is a simple service that allow you to update multiple social networks (Facebook, Twitter, Jaiku ecc...) with a single post. You can find complete source code and documentation on the official website: http://code.google.com/p/pyngfm/

    Please contact me if you have any suggestion or if you find any bug in the code, so I'll be able to fix it.

    read more

    comments

Page 1 / 2 »

social