Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overwriting the builtin Python Print [closed]

Tags:

python

rich

Nowadays I pretty much only using the Python Rich implementation for printing. i.e from rich import print.

Rather than adding this to every script I write, is there a way to replace the built-in Python print with the Rich implementation?

like image 289
felix001 Avatar asked Oct 28 '25 14:10

felix001


1 Answers

You can create a script usercustomize.py inside the user site-packages directory which performs the import and assigns it to the builtins:

import builtins
import rich

builtins.print = rich.print

Also check the documentation of the site module for more information (the same can be achieved for all users via sitecustomize.py).

like image 116
a_guest Avatar answered Oct 31 '25 05:10

a_guest