471,353 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

should i switch to IPYTHON interpreter? What is the killer feature of it?

I know IPython is another interpreter for Python and was wondering
what people liked about it and if I should switch to it.

If it is so good then why is it not part of the standard Python
tarball?

Chris
Jul 18 '05 #1
14 2838
se******@spawar.navy.mil (Christian Seberino) writes:
I know IPython is another interpreter for Python and was wondering
what people liked about it and if I should switch to it.
Some things i like are .....

Typing ? after a function name gives you the function definition and
docstrings for the function. i.e arange? returns

Type: builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form: <built-in function arange>
Namespace: Interactive
Docstring:
arange(start, stop=None, step=1, typecode=None)

Just like range() except it returns an array whose type can be
specified by the keyword argument typecode.

Normal shell commands like cd & ls are available

Tab completion for keywords and methods etc (you can get this in the
standard python shell as well of course)

Heaps more features but those are the killers for me (YMMV)
If it is so good then why is it not part of the standard Python
tarball?


No idea. It's no big deal for me to download it separately and install
it. You could ask the same question about many other Python packages,
if they were all included the distribution would start getting a bit
big I think.

Anyway give IPython a try I think you will like it.

Sean

--
"Hver sin smak", sa vintapperen, han drakk mens de andre sloss.
Jul 18 '05 #2
Sean Richards wrote:

Tab completion for keywords and methods etc (you can get this in the
standard python shell as well of course)


You can? How?

--Irmen

Jul 18 '05 #3
On 9 Dec 2003 16:19:35 -0800, se******@spawar.navy.mil (Christian
Seberino) wrote:
I know IPython is another interpreter for Python and was wondering
what people liked about it and if I should switch to it.

If it is so good then why is it not part of the standard Python
tarball?

Chris

I use it on Win32 and like that it provides a simpler/more direct
interface to the file system. I.e., I can do things such as "cd
blahblahblah" and change the directory, rather than importing os and
calling os.chdir("blahblah"), "ls" instead of os.listdir('.'), and
that sort of thing. Also, you can create your own command aliases,
along the lines of cshrc, bash, etc.

Another feature I've used, at least occasionally, is the ability to
save the session history. When I'm exploring a module I've not used
before, I do a lot of schtuff that doesn't work, get it to work, then
move forward (not work, work, not work, work). By the time I've
reached my goal, though, I've become addled and have forgotten which
pieces parts works and which didn't. With IPython, I can save that
history and review what worked and what didn't, delete the chaff and
try the wheat again later.

At least one reason it's not part of the standard tarball is that it's
owned by a different group of people.

--dang
p.s.
One could argue that my approach to learning new modules could use
improvement. And while that may be true, I've found that learning to
recognize error messages, and what causes them, makes it easier to
help others.
Jul 18 '05 #4
On Wed, 10 Dec 2003 11:19:21 +0100, Irmen de Jong
<irmen@-NOSPAM-REMOVETHIS-xs4all.nl> wrote:
Sean Richards wrote:

Tab completion for keywords and methods etc (you can get this in the
standard python shell as well of course)


You can? How?

--Irmen


Press tab after typing part of the keyword/method.

This assumes you're *not* using Win32. The documentation says that
IPython requires the GNU readline function, which I guess isn't
available with Win32. Neither is color highlighting.

--dang
Jul 18 '05 #5
Dang Griffith wrote:
Tab completion for keywords and methods etc (you can get this in the
standard python shell as well of course)


You can? How?

--Irmen

Press tab after typing part of the keyword/method.


Sean was talking about the 'standard python shell' so I tried
the default python (2.3) on my mandrake 9.2 box.
It doesn't work, it just inserts a tab character.

--Irmen

Jul 18 '05 #6
<snip>
One could argue that my approach to learning new modules could use
improvement. And while that may be true, I've found that learning to
recognize error messages, and what causes them, makes it easier to
help others.

I would say you have nothing to apologize for, this approach to learning new
modules sounds strikingly similar to my own. It's part of what I think is a
big advantage to Python (and similar scripting languages), that you can
engage in a highly efficient, quick turnaround, exploratory process, without
the overhead and delay of compile/correct-syntax-errors/compile/link/run.
The immediate feedback (and sometimes, gratification) allows you to stay in
that high-intensity mental zone, without the distractions of awkward
meta-tasks, for hours at a time (or days or weeks!).

-- Paul
Jul 18 '05 #7
> Sean was talking about the 'standard python shell' so I tried
the default python (2.3) on my mandrake 9.2 box.
It doesn't work, it just inserts a tab character.


I use rlcompleter2 for this - in the standard shell. Very nice - but I think
I've got to take a look at IPython, too.

Diez
Jul 18 '05 #8
Irmen de Jong wrote:
Dang Griffith wrote:
Tab completion for keywords and methods etc (you can get this in the
standard python shell as well of course)
You can? How?

--Irmen


Press tab after typing part of the keyword/method.

Sean was talking about the 'standard python shell' so I tried
the default python (2.3) on my mandrake 9.2 box.
It doesn't work, it just inserts a tab character.

--Irmen

You need an startup-file for python.

(I copied this together out of python-news-mail (thank you once again)
and some own ideas)

..pystartup in your home-dir

# Add auto-completion and a stored history file of commands to your Python
# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is
# bound to the Esc key by default (you can change it - see readline docs).
#
# Store the file in ~/.pystartup, and set an environment variable to point
# to it, e.g. "export PYTHONSTARTUP=/max/home/itamar/.pystartup" in bash.
#
# Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the
# full path to your home directory.

import atexit
import os
import readline
import rlcompleter

historyPath = os.path.expanduser("~/.pyhistory")
historyTmp = os.path.expanduser("~/.pyhisttmp.py")

endMarkerStr= "# # # histDUMP # # #"

saveMacro= "import readline;
readline.write_history_file('"+historyTmp+"'); print '####>>>>>>>>>>';
print ''.join(filter(lambda lineP: not
lineP.strip().endswith('"+endMarkerStr+"'),
open('"+historyTmp+"').readlines())[:])+'####<<<<<<<<<<'"+endMarkerStr

readline.parse_and_bind('tab: complete')
readline.parse_and_bind('\C-w: "'+saveMacro+'"')

def save_history(historyPath=historyPath, endMarkerStr=endMarkerStr):
import readline
readline.write_history_file(historyPath)
# Now filter out those line containing the saveMacro
lines= filter(lambda lineP, endMarkerStr=endMarkerStr: not
lineP.strip().endswith(endMarkerStr), open(historyPath).readlines())
open(historyPath, 'w+').write(''.join(lines))

if os.path.exists(historyPath):
readline.read_history_file(historyPath)

atexit.register(save_history)

del os, atexit, readline, rlcompleter, save_history, historyPath,
historyTmp, endMarkerStr, saveMacro
(I hope spaces will survive mailing)

Additionaly you need to
~# export PYTHONSTARTUP=/root/.pystartup

You can do this e.g. in .profile
Pressing tab completes the input like common unix-shells.
Pressing CTRL-w gives You an python code to print the history-file (or
parts of it -- there's a [:] in the command that You can replace by
[-50:]; which will give you the last 50 lines)
cu cbf


Jul 18 '05 #9
Tab completion for keywords and methods etc (you can get this in the
standard python shell as well of course)

You can? How?


Press tab after typing part of the keyword/method.


Sean was talking about the 'standard python shell' so I tried
the default python (2.3) on my mandrake 9.2 box.
It doesn't work, it just inserts a tab character.


Put this in ~/.pythonrc, and setup the PYTHONSTARTUP environment variable to
point to it: export PYTHONSTARTUP=~/.pythonrc
# ~/.pythonrc
# enable syntax completion
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
--
Дамјан (jabberID:da****@bagra.net.mk)

I believe the technical term is "Oops!"
Jul 18 '05 #10
дамјан г. wrote:

Put this in ~/.pythonrc, and setup the PYTHONSTARTUP environment variable to
point to it: export PYTHONSTARTUP=~/.pythonrc
# ~/.pythonrc
# enable syntax completion
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")


I say thank you ! This works like a charm.
Somehow I've never discovered rlcompleter... :-)

--Irmen

Jul 18 '05 #11
Dang Griffith <no*****@noemail4u.com> writes:
On Wed, 10 Dec 2003 11:19:21 +0100, Irmen de Jong
<irmen@-NOSPAM-REMOVETHIS-xs4all.nl> wrote:
Sean Richards wrote:

Tab completion for keywords and methods etc (you can get this in the
standard python shell as well of course)


You can? How?

--Irmen


Press tab after typing part of the keyword/method.

This assumes you're *not* using Win32. The documentation says that
IPython requires the GNU readline function, which I guess isn't
available with Win32. Neither is color highlighting.

--dang


Actually you can get all this on win32 if you use the cvs version of
IPython and Gary Bishop's Python readline module. There is a URL
and instructions on how to set it up here.
http://www.scipy.net/pipermail/ipyth...er/000094.html
The Python readline module needs ctypes so get that as well.
Works with Python 22 and 23 and gives you readline functionality and
colour highlighting when using IPython under win32.

Sean
--
"Hver sin smak", sa vintapperen, han drakk mens de andre sloss.
Jul 18 '05 #12
?????? ?. <mk@net.mail.penguinista> wrote:
# ~/.pythonrc
# enable syntax completion
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")


This will work on win32 as well if you download ctypes and then my
python implementation of gnu readline from

http://prdownloads.sourceforge.net/u...1.zip?download

It also includes the ability to translate ascii color escapes into
colors on windows for use with iPython.

gb

Jul 18 '05 #13
Christian Seberino wrote:
I know IPython is another interpreter for Python and was wondering
what people liked about it and if I should switch to it.
As the ipython developer, you could say that I'm biased :) But you could
simply try it and see if you like it. It's a simple python package with no C
dependencies (under *nix), so getting it going is pretty straightforward.

I personally can't stand using the standard python shell anymore, which to me
feels like a crippled toy. But YMMV.

As Sean pointed, some of its nicer features (readline and color support) are
finally available to Windows XP/2k users, but only with CVS code. I'll be
making a new release soon-ish, but I want to clean some other outstanding
small bugs before that.
If it is so good then why is it not part of the standard Python
tarball?


I'd like it to, but I haven't even considered proposing such an idea. Right
now the ipython internals are a heinous mess, and nobody in their sane mind
would accept to maintain such a codebase. But there's hope for a rewrite with
the help of some dedicated users (I have very limited time for its
development). If we manage to clean it up completely, it might be conceivable
to propose it for the standard distribuition (not as a replacement, but as an
alternative: it's still slower to load and more complex code).

Regards,

Fernando.
Jul 18 '05 #14
"Gary Bishop" <gb@cs.unc.edu> wrote in message news:<3f********@news.unc.edu>...
?????? ?. <mk@net.mail.penguinista> wrote:
# ~/.pythonrc
# enable syntax completion
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")


This will work on win32 as well if you download ctypes and then my
python implementation of gnu readline from

http://prdownloads.sourceforge.net/u...1.zip?download


Brilliant! Thank you very much indeed.

I would add a warning for those Windows users who aren't also Linux
users: by default you'll need to use Ctrl-D to exit the interpreter
rather than Ctrl-Z. (I imagine this could be changed; I've given the
source no more than a cursory glance).

TJG
Jul 18 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Yaroslav Bulatov | last post: by
1 post views Thread by Ismael Herrera | last post: by
3 posts views Thread by Dave Merrill | last post: by
28 posts views Thread by grahamd | last post: by
1 post views Thread by Jeremy Jones | last post: by
1 post views Thread by Michael Tobis | last post: by
5 posts views Thread by Lou Pecora | last post: by
reply views Thread by Karlo Lozovina | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.