How To Change Package Representation on Shell?

Chris Angelico rosuav at gmail.com
Wed Apr 1 16:41:33 EDT 2020


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


More information about the Python-list mailing list