- Internal and external hyperlinks
- Automatic module reload
- Run demos
What do you think of the following innocuous Python code ?
from gevent import monkey
monkey.patch_all(thread=False, select=False)
import requests
requests.get('http://i-do-not-exist.com')
print('THIS WILL NEVER BE PRINTED !!!')
Guess what ? The string message will never get printed :(
Simply remove the monkey.patch_all
line and you'll …
Une courte présentation que j'ai donné cette après-midi à Voyages-sncf.com Technologies :
Les slides sont accessibles ici en plein écran.
Last week, my father asked me if I could find make a backup of an old lovely voicemail message he had.
I wrote a short Python script to accomplis this:
twiml_url = 'https://handler.twilio.com/twiml/EH9515e9e0d2fb81f27d75a493225ae703'
client = Client(os.environ['TWILIO_ACCOUNT_SID'], os.environ['TWILIO_AUTH_TOKEN'])
client.calls.create(to='+33241XXXXXX …
Exemple d'utilisation en notebook Python:
Sujet : http://www.xavierdupre.fr/app/ensae_teaching_cs/helpsphinx3/notebooks/TD2A_eco_API_SNCF.html
Corrigé: https://github.com/sdpython/ensae_teaching_cs/blob/master/_doc/notebooks/td2a_eco/TD2A_eco_API_SNCF_corrige.ipynb
In this blog post, I'm going to demonstrate how to reuse WiseMapping HTML+JS rendering engine to easily visualize...
text-based mindmaps like this one have many benefits they are readable as-it-is they don't require any tool to be edited they follow the UNIX tenets
For the impatient ones, here is …
This week I wrote a small Python script, that can generate a mindmap from a simple indented text input like this:
Winter december january february Spring march april may Summer june july august Autumn september october november
The command: ./graphviz_mindmap.py seasons.txt
.
The results, with various layout
parameters:
Another …
Due to a long standing bug, no history file will be kept of the commands you enter in an interactive shell when using a Python 3 virtualenv.
I found out a simple workaround. Simply put the following in your ~/.pythonrc
:
import atexit, os, readline, sys
if sys.version_info >= (3, 0 …
En mars dernier, j'ai participé à la Battledev de RegionJobs.
Et c'était super fun.
Pour ceux qui ne connaissent pas, c'est une compétition de programmation en ligne, où l'on doit résoudre 5 questions de difficulté croissante en 2 heures.
J'ai eu l'occasion d'y participer avec quelques collègues, et ça a …
Last week, I made up a basic TCP server in Python, to receive log lines. To split log lines, I used the ascii line feed ascii character : \n aka 0xa in hexadecimal.
But then I wondered : could this byte appear elsewhere in the UTF8-encoded strings of text I was sending …
Le mois dernier j'ai rapidement présenté le language Python et les frameworks web existants à mon équipe à Voyages-Sncf.com.
Les slides sont accessibles ici, ainsi que les sources Markdown pour Reveal.js.
Il …
Python generators are awesome. Why ?
- their syntax is simple an concise
- they lazily generate values and hence are very memory efficient
- bonus point: since Python 3 you can chain them with
yield from
Their drawback ? They can be iterated only once, and they hide the iterable length.
I took an …
First, lets mention Git Bash (aka msysgit) : the old version was a PITA to extend with additional packages (e.g. adding common C libs like libxml), and the new one (renamed Git for Windows), is based on MSYS2, but does not include a package manager.
Hence, we were left with …
... and the standard UNIX tool zipinfo
cannot display them !
So here is Python one-liner to extract them, and other useful meta informations:
python -c "import json, sys, zipfile; json.dump([{k: str(getattr(i, k)) for k in zipfile.ZipInfo.__slots__} for i in zipfile.ZipFile(sys.argv[1]).infolist …
Say you are generating a colored diff output with the standard difflib
Python package:
diff = difflib.ndiff(file1_lines, file2_lines)
print('\n'.join(diff))
Now, I'll show you how to write a simple color_diff
function that you can use to color your diff like this:
diff = difflib.ndiff(file1_lines, file2_lines)
diff …
Nylas provides a modern developer
platform for email, contacts, and calendar. Stop fighting old protocols,
and start building great products