How To Change Package Representation on Shell?

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Wed Apr 1 17:02:18 EDT 2020


Having fun with packages

Since i don't master packaging completely thought there was a __repr__.py
protocol nearby!
Might be useful maybe to replace it by a help message

Kind Regards,

Abdur-Rahmaan Janhangeer
compileralchemy.com <https://www.compileralchemy.com> | github
<https://github.com/Abdur-rahmaanJ/>
Mauritius


On Thu, Apr 2, 2020 at 12:41 AM Chris Angelico <rosuav at gmail.com> wrote:

> On Thu, Apr 2, 2020 at 7:37 AM Rhodri James <rhodri at kynesim.co.uk> wrote:
> >
> > On 01/04/2020 21:22, Abdur-Rahmaan Janhangeer wrote:
> > > Greetings list,
> > >
> > > I have a custom package.
> > >
> > >>>> import package
> > >>>> package
> > > <module 'package' from '<path>'>
> > >
> > > what do i have to modify from my package to have like
> > >
> > >>>> package
> > > Hi!
> >
> > Do you mean "How do I override the str() or repr() of a module"?  I
> > don't think you can.
> >
>
> Not easily. It is possible but only by replacing the module as you're
> importing it.
>
> Also, I'm not sure why you would even need/want to do this - Abdur,
> can you elaborate on the use-case here?
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list