RT @brettsky@twitter.com

The Python Launcher for Unix now has a man page! github.com/brettcannon/python-
I also created a control flow diagram to help explain how the Launcher decides what executable to use; see github.com/brettcannon/python-
I now consider the Launcher at RC stage; only (potential) code cleanup left!

🐦🔗: twitter.com/brettsky/status/13

So Google just asked me to prove my age to watch a youtube vid by either providing my credit car or my identity card.
Well, nope, nope, nope.

Can you guess what it does ?

It's for when I want to see what's in a generator, but I'm too lazy to go back to the begining of the line and do "list(gen)", so I have this trick to be able to do "gen /l".

Afficher le fil de discussion

Personally I have some dirty hacks in my PYTHONSTARTUP:

class L(list):
def __truediv__(self, other):
return list(other)
def __rtruediv__(self, other):
return list(other)
def __call__(self, *args, **kwargs):
return list(*args, **kwargs)
l = L()

Afficher le fil de discussion

And so much more. You can customize your whole Python shell experience, tailored to your daily needs!

Afficher le fil de discussion

import readline
readline.parse_and_bind("tab: complete")
except ImportError:

Enable tab completion in the regular python shell.

Afficher le fil de discussion

from __future__ import print_function

If you are stuck in python 2, use print_function anyway

Afficher le fil de discussion

import numpy as np
import pandas as pd
except ImportError:

If pandas and numpy are installed, import them

Afficher le fil de discussion

TEMP_DIR = Path(tempfile.gettempdir()) / "pythontemp")
except Exception as e:

Always have a ready to use temporary directory

Afficher le fil de discussion

from IPython import get_ipython
get_ipython().magic("%load_ext ipython_autoimport")

Try to trigger ipython auto import if it's installed

Afficher le fil de discussion

null = None
true = True
false = False

So that you can copy/paste JSON and get Python automatically.

Afficher le fil de discussion

Some stuff you can do:

from datetime import datetime, date, timedelta
def now():
return datetime.now()
def today():
return date.today()

So you always have the current date and time at your fingertip.

Afficher le fil de discussion

For Windows, type in a terminal:

setx PYTHONSTARTUP c:\path\to\a\script.py

For Linux, put in your .bashrc:

export PYTHONSTARTUP=/path/to/a/script.py

Reboot, and voilà, script.py runs at the start of any shell. Put what you want in it!

Afficher le fil de discussion

I know, I know, I'm repeating myself, but if you are not using PYTHONSTARTUP, you are missing out.

It lets you run code anytime a shell starts.

E.G: doing maths in a shell or notebook all the time ? Use PYTHONSTARTUP to get an automatic "from math import *"!

It's easy:

Always get the python interpreter with the highest version on linux:

LASTEST_PYTHON=$(ls /usr/bin/python3.* | egrep -v "config|m$" | tail -n 1)


$ python3.9 -m pip install pyzmq
Defaulting to user installation because normal site-packages is not writeable

Ohhhh, I like that!

No more --user!

RT @anthonypjshaw@twitter.com

🚀Just released Pyjion 0.14.0, the Python byte code JIT compiler project I'm working on that uses .NET5's JIT engine to compile Python functions into machine code.
This release has a lot of performance gains written over the past fortnight. Fannkuch is +15-20%, n-body is +30%

🐦🔗: twitter.com/anthonypjshaw/stat

RT @tenderlove@twitter.com

Found a photo from that time I tried doing pear programming

🐦🔗: twitter.com/tenderlove/status/


Le réseau social de l'avenir : Pas d'annonces, pas de surveillance institutionnelle, conception éthique et décentralisation ! Possédez vos données avec Mastodon !