On 10/22/2009 07:41 PM, Noufal Ibrahim wrote:
On Thu, Oct 22, 2009 at 6:43 PM, Amit Saha<lists.amits...@gmail.com>  wrote:
 Hello:

 I have been using CPython as a calculator, while I do all those number
 crunching in C. SO, 'import math' is a must.

 This is what I did:

 - Create a file: .pythonrc in my $HOME and place this line:

There are other goodies you can put there as well. I used to have

import readline
readline.parse_and_bind("tab: complete")

in there so that the default interpreter would get tab completion.

I also have this is my .pythonrc:

import os
import readline
histfile = os.path.join(os.environ["HOME"], ".pyhist")
try:
    readline.read_history_file(histfile)
except IOError:
    pass
import atexit
atexit.register(readline.write_history_file, histfile)
del os, histfile

This lets you save the history of every thing you type in your interpreter session much like the bash history functionality. This is immensely useful when I am trying out stuff on the prompt before creating a script.

Of course all this also comes built-in with the Ipython environment, but I never really got hooked on to that.

Anyways, besides the tip, I'd also like to point out to the 'atexit' module which the above tip uses. It is included in the stdlib and can prove to be quite useful at times. That one is good to know about.

cheers,
- steve
--
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to