On Thu, Apr 02, 2020 at 10:44:02AM +0400, Abdur-Rahmaan Janhangeer wrote:
Let's say i have a package.
import package package
would it be nice to be able to change the repr of the package to
package package something some message ....
?
I don't know, would it be nice? For what purpose? What will the message be? Where does the message come from? The Python shell just prints the repr() of the object. If you want it to print something different, you can install a custom display hook: py> from types import ModuleType py> def thingy(obj): ... if isinstance(obj, ModuleType): ... print("module %s is amazing!" % obj.__name__) ... print("...and Python is great!") ... else: ... print(repr(obj)) ... py> sys.displayhook = thingy py> 'hello' 'hello' py> math module math is amazing! ...and Python is great! -- Steven