2

I am implementing a shell which does similarly like python interactive shell.

I am using raw_input and cmd2 library for it, now I need to implement a function which does exactly like "help" command. That is, it can show a large chunk of text which may exceed screen height and allow user to scroll down/up, and support Linux shell short-cut as well.

I don't know if I can do it without involving curse library. If I have to, any suggestions to integrate it with raw_input, cmd2 library?

thanks

5
  • Can you please elaborate on what you mean with a plain text library, and what you want to avoid with a curses library? Commented Feb 24, 2014 at 22:53
  • Bindings to curses is part of Pythons stand lib and it's really not that bad docs.python.org/2/library/curses.html Commented Feb 24, 2014 at 22:53
  • more does not let you scroll up--only down. Perhaps you're referring to less? Commented Feb 24, 2014 at 22:53
  • @Krumelur please see my updates Commented Feb 24, 2014 at 23:09
  • others, please see my comment. Commented Feb 24, 2014 at 23:16

1 Answer 1

2

Python's help command actually uses less (or more on some platforms) behind the scenes. You can access the same functionality:

import pydoc
pydoc.pager("A very long string")
Sign up to request clarification or add additional context in comments.

1 Comment

Can't believe it's simple like this! next time I should ask my question in a direct way. thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.