Re: Print docstrings to shell

2011-02-02 Thread Steven D'Aprano
On Tue, 01 Feb 2011 16:11:51 -0800, Gnarlodious wrote: > Can I run a script in bash and print out its docstrings to the bash > shell? I tried this at the end: [...] > However in the interactive shell it prints out the class structure > nicely. What I really want to see is this output in the bash w

Re: Print docstrings to shell

2011-02-01 Thread Gnarlodious
Thank you for the help, I learned a few things. The André solution renders the colors but needs q-q to quit. The Carl solution 1 prints colors and requires q to quit. The Carl solution 2 prints colorlessly, it looks good for exporting to a file. Everything I need. -- Gnarlie http://Gnarlodious.com

Re: Print docstrings to shell

2011-02-01 Thread Carl Banks
On Feb 1, 4:11 pm, Gnarlodious wrote: > Can I run a script in bash and print out its docstrings to the bash > shell? I tried this at the end: > > print(help(__file__)) > > Runnig the script: > python ~/Sites/Sectrum/Harmonics.py > > but all it spit out was: > > no Python documentation found for '~

Re: Print docstrings to shell

2011-02-01 Thread André Roberge
On Tuesday, February 1, 2011 9:21:48 PM UTC-4, André Roberge wrote: SNIP > > === > import pydoc > import os > import sys > > '''this is a test''' > > class A(object): > '''docstring''' > pass > > _path, _file_name = os.path.split(__file__) > _module_name = _file_name[:-3] > sys.

Re: Print docstrings to shell

2011-02-01 Thread André Roberge
On Tuesday, February 1, 2011 9:05:28 PM UTC-4, Gnarlodious wrote: > On Feb 1, 5:30 pm, André Roberge wrote: > > > test.py== > > import pydoc > > > > '''this is a test''' > > > > class A(object): > >         '''docstring''' > >         pass > > > > print(pydoc.help(__file__[:-3]))

Re: Print docstrings to shell

2011-02-01 Thread Gnarlodious
On Feb 1, 5:30 pm, André Roberge wrote: > test.py== > import pydoc > > '''this is a test''' > > class A(object): >         '''docstring''' >         pass > > print(pydoc.help(__file__[:-3])) > = > > python test.py OK that works, but only if I cd into the folder of th

Re: Print docstrings to shell

2011-02-01 Thread André Roberge
On Tuesday, February 1, 2011 8:11:51 PM UTC-4, Gnarlodious wrote: > Can I run a script in bash and print out its docstrings to the bash > shell? I tried this at the end: > > print(help(__file__)) > > Runnig the script: > python ~/Sites/Sectrum/Harmonics.py > > but all it spit out was: > > no Py

Print docstrings to shell

2011-02-01 Thread Gnarlodious
Can I run a script in bash and print out its docstrings to the bash shell? I tried this at the end: print(help(__file__)) Runnig the script: python ~/Sites/Sectrum/Harmonics.py but all it spit out was: no Python documentation found for '~/Sites/Sectrum/Harmonics.py' However in the interactive