[Python-ideas] Re: Changing Package Representation On Shell

2020-04-03 Thread Wes Turner
__doc__ https://docs.python.org/3/library/pydoc.html describes the help() function; which you can also call with: $ pydoc modname $ python -m pydoc modname IPython: >>> help(modname) >>> ?modname >>> modname? >>> !pydoc modname >>> !python -m pydoc modname https://ipython.readthedocs.io/en/s

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-03 Thread Chris Angelico
On Sat, Apr 4, 2020 at 7:02 AM Christopher Barker wrote: > So if folks think it's a good idea to allow modules to have a custom __str__: > it would be nice to add that feature to Python. > > I'm not saying I advocate for that -- but it's not completely unreasonable. > It's not unreasonable, I ag

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-03 Thread Christopher Barker
I think there's been some confusion with regard to this idea, leading to a combination of technical details vs the merits of the idea. So I'm going to summarize a bit what I think the discussion has yielded: Technical issues: The __repr__ and __str__ are defined on the class, not instances of a

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Abdur-Rahmaan Janhangeer
Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius On Fri, Apr 3, 2020 at 4:04 AM Steven D'Aprano wrote: > ... > Personally, I might make and use a display hood to show the first line > of a modul

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Abdur-Rahmaan Janhangeer
Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius On Fri, Apr 3, 2020 at 3:55 AM Steven D'Aprano wrote: > On Thu, Apr 02, 2020 at 07:18:47PM +0400, Abdur-Rahmaan Janhangeer wrote: > > > Out of cu

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Abdur-Rahmaan Janhangeer
Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius On Fri, Apr 3, 2020 at 2:21 AM Andrew Barnert wrote: > On Apr 2, 2020, at 13:35, Abdur-Rahmaan Janhangeer > wrote: > But nobody’s mentioned impl

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Wes Turner
IDK what you'd grep for in these; if it's not there you could send a PR that adds more greppable keywords or cross-:ref:'s the sys.displayhook docs like this: :func:`sys.displayhook` https://docs.python.org/3/library/sys.html#sys.displayhook https://github.com/python/cpython/blob/master/Doc/librar

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Steven D'Aprano
On Fri, Apr 03, 2020 at 08:00:38AM +1100, Steven D'Aprano wrote: > But I can tell you that this will 99.99% be rejected. And if it is > accepted, I can tell you that the first time you get hit by a massive > wall of text from a package docstring in an exception or some other use > of repr()

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Steven D'Aprano
On Thu, Apr 02, 2020 at 07:18:47PM +0400, Abdur-Rahmaan Janhangeer wrote: > Out of curiosity how did you learn about sys.displayhook? 20+ years of using Python, experimenting at the interpreter, reading the documentation, blog posts, etc. I have no idea *specifically* where I learned it. I did

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Andrew Barnert via Python-ideas
On Apr 2, 2020, at 13:35, Abdur-Rahmaan Janhangeer wrote: > >> On Thu, Apr 2, 2020 at 8:15 PM Andrew Barnert wrote: >> >> Why should modules break all of that, and be different from strings, tuples, >> functions, classes, etc.? > > python-ideas is for ideas without worrying about implementati

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Steven D'Aprano
On Fri, Apr 03, 2020 at 12:28:36AM +0400, Abdur-Rahmaan Janhangeer wrote: > This means we have a __repr__ option in packages (Without Steven's snippet > above)? There is no "hook" in the package file structure where you can customize the repr. It is built into the module type. Once loaded, pac

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Abdur-Rahmaan Janhangeer
Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius On Fri, Apr 3, 2020 at 12:34 AM Chris Angelico wrote: > > You can mess with anything on a module if you subclass ModuleType and > stick your one

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Wes Turner
This prints modname.__doc__ / help(modname) / inspect.getdoc(modname) with IPython / Jupyter + ipykernel: >>> modname? This prints something like inspect.getsource(modname) >>> modname?? https://ipython.readthedocs.io/en/stable/interactive/python-ipython-diff.html#accessing-help https://docs.p

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Abdur-Rahmaan Janhangeer
Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius On Thu, Apr 2, 2020 at 8:15 PM Andrew Barnert wrote: > > Why should modules break all of that, and be different from strings, > tuples, functions

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Chris Angelico
On Fri, Apr 3, 2020 at 7:30 AM Abdur-Rahmaan Janhangeer wrote: > > > Kind Regards, > > Abdur-Rahmaan Janhangeer > compileralchemy.com | github > Mauritius > > > On Thu, Apr 2, 2020 at 9:52 PM Brett Cannon wrote: >> >> >> That's what help() is for. The __repr__ is meant to help during development

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Abdur-Rahmaan Janhangeer
Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius On Thu, Apr 2, 2020 at 9:52 PM Brett Cannon wrote: > > That's what help() is for. The __repr__ is meant to help during > development with some su

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Brett Cannon
On Thu, Apr 2, 2020 at 8:22 AM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Thanks for the snippet, > > Was wondering if given as a package option, > we might display the module's help info. > That's what help() is for. The __repr__ is meant to help during development with some succi

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Andrew Barnert via Python-ideas
On Apr 1, 2020, at 23:47, 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 think so. Objects

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Abdur-Rahmaan Janhangeer
Thanks for the snippet, Was wondering if given as a package option, we might display the module's help info. Out of curiosity how did you learn about sys.displayhook? Thanks. Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Steven D'Aprano
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'