Re: h(re) for help, import re - on NameError

2016-09-23 Thread Chris Angelico
On Fri, Sep 23, 2016 at 4:40 PM, Peter Otten <__pete...@web.de> wrote: > By the way, the current help() already loads a module if you pass its name > as a string: > Yes, which is the basis of my alternate exec trick: exec(tb.tb_frame.f_code, tb.tb_frame.f_globals, {n: n}) Basically it creates a

Re: h(re) for help, import re - on NameError

2016-09-23 Thread Peter Otten
Veek M wrote: > Is there a way to use .pythonrc.py to provide a help function that > autoloads whatever module name is passed like so: By the way, the current help() already loads a module if you pass its name as a string: $ echo 'print("importing foo")' > foo.py $ python3 Python 3.4.3

Re: h(re) for help, import re - on NameError

2016-09-23 Thread Veek M
Chris Angelico wrote: > On Thu, Sep 22, 2016 at 8:10 PM, Veek M wrote: >> Is there a way to use .pythonrc.py to provide a help function that >> autoloads whatever module name is passed like so: >> \>>> h(re) >> >> I tried inheriting site._Helper and overriding __init__ and

Re: h(re) for help, import re - on NameError

2016-09-22 Thread Chris Angelico
On Thu, Sep 22, 2016 at 8:10 PM, Veek M wrote: > Is there a way to use .pythonrc.py to provide a help function that > autoloads whatever module name is passed like so: > \>>> h(re) > > I tried inheriting site._Helper and overriding __init__ and __call__ but > that didn't

h(re) for help, import re - on NameError

2016-09-22 Thread Veek M
Is there a way to use .pythonrc.py to provide a help function that autoloads whatever module name is passed like so: \>>> h(re) I tried inheriting site._Helper and overriding __init__ and __call__ but that didn't work, also I don't know how to deal/trap/catch the NameError (no quotes on h(re))