LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-25-2010, 01:11 PM   #1
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 106

Rep: Reputation: 17
Python: bash-shell-like less functionality in the python shell


Hello,

Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?

Example:
Code:
>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...
I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.

With thanks,
Narnie
 
Old 06-25-2010, 01:50 PM   #2
robotsari
LQ Newbie
 
Registered: Jun 2010
Location: boston & sf bay, depending on the day
Distribution: ubuntu, rhel, debian
Posts: 20

Rep: Reputation: 1
Hi Narnie,

When I do this I do get the help page in a less-type viewer. I'm running

~$ python -V
Python 2.6.5

on ubuntu 10.04.
 
Old 06-26-2010, 07:29 AM   #3
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 106

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by robotsari View Post
Hi Narnie,

When I do this I do get the help page in a less-type viewer. I'm running

~$ python -V
Python 2.6.5

on ubuntu 10.04.
I should have mentioned that I'm using the IDLE IDE for my messing around (I'm just learning programming and starting with Python, but I'm quite facile with bash scripting).

I get less-type functionality in the bash shell, but not in the IDLE python shell.

However, I'll check IDLE to see if there is a command line option to start it with python -V. That's a great tip

Thank you,
Narnie
 
Old 06-28-2010, 12:09 PM   #4
robotsari
LQ Newbie
 
Registered: Jun 2010
Location: boston & sf bay, depending on the day
Distribution: ubuntu, rhel, debian
Posts: 20

Rep: Reputation: 1
Hmm. python -V simply displays the version of Python that you're running; I was thinking perhaps you were running an older version of Python.

I somewhat suspect that the IDLE shell doesn't actually enable what you're looking to do 8/

Try using ipython (in the universe; sudo apt-get install ipython). It combines some of the best aspects of the bash shell, python interpreter, and IDLE - for example you can navigate directories with commands such as cd and ls, and you can enter in Python code and run scripts (using the "run" command, eg > run test.py). And, it displays "help" as you want it to! Basically, they simply implemented the python interpreter on top of a normal shell.

Another option I haven't tried before is bpython, which looks really interesting; it also supplies syntax highlighting (I thought ipython provided syntax highlighting, but I just installed it here on my work computer and it apparently doesn't have it).
 
Old 06-29-2010, 12:25 PM   #5
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 106

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by robotsari View Post
Hmm. python -V simply displays the version of Python that you're running; I was thinking perhaps you were running an older version of Python.

I somewhat suspect that the IDLE shell doesn't actually enable what you're looking to do 8/

Try using ipython (in the universe; sudo apt-get install ipython). It combines some of the best aspects of the bash shell, python interpreter, and IDLE - for example you can navigate directories with commands such as cd and ls, and you can enter in Python code and run scripts (using the "run" command, eg > run test.py). And, it displays "help" as you want it to! Basically, they simply implemented the python interpreter on top of a normal shell.

Another option I haven't tried before is bpython, which looks really interesting; it also supplies syntax highlighting (I thought ipython provided syntax highlighting, but I just installed it here on my work computer and it apparently doesn't have it).
Sarina,

You are very kind to provide me so much followup.

I have done some reading and it is in fact that the IDLE shell isn't a "proper" shell. I will look into you solution when I get home. I'm always interested in trying in out and it's being in the repos will make it even easier.

Thanks very much for the suggestion.

Yours,
Narnie

PS
Hoping it does code completion!!!

PPS
Loving how it sound like it makes it easier to change working directory, etc.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PYTHON or Bash Shell Scripting? latinmusic74 Linux - Newbie 4 06-04-2010 10:58 AM
Python: can you determine the type of shell the user is using (tcsh, bash, etc)? BrianK Programming 1 01-20-2010 09:43 PM
Python shell help (using elif) danred Linux - General 8 10-20-2009 03:55 AM
python: can you update the current shell from python? BrianK Programming 4 01-31-2008 12:18 AM
getting out of the Python Shell! Colonel Panic Programming 2 08-19-2001 06:26 PM


All times are GMT -5. The time now is 06:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration