Jump to content
xisto Community
rob86

Pythons Idle Shell: How Do I repeat Last Line? In most shells, its the up arrow

Recommended Posts

I've been playing with IDLE - Python's shell (the >>> part, not the editor part) to experiment with python a bit as it's a bit better than using a terminal. It's missing one important feature, and that's the common up-arrow repeat last lines I'm sure you're all familiar with as it's in pretty much everything. Am I missing something, or is this not possible in IDLE? When testing one liners, I hate having to retype the whole line.

Share this post


Link to post
Share on other sites

I have not used IDLE, but they could be using their own custom shell which does not have the up-arrow, last-line feature. If the up-arrow feature is a must-have feature, then you could try out other Python IDEs and see if it is available for them. As a last resort, you can run Python in interactive mode:

CONSOLE
python -i

Share this post


Link to post
Share on other sites

Your in luck, after a ten minute search i came across this - http://bugs.python.org/issue2704. Obviously i cant verify that the patch works, but it could be your best bet for windows without VIM or Emacs. Actually I'm fairly sure you can use Emacs with Python on windows if i remember correctly. Although Emacs will take 2-4 days to get a handle on, but its kinda cool.

http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

I'm actually using Ubuntu. That's the problem I've been having with PyShell but I'm not quite sure how to go about patching it myself. I downloaded the most recent PyShell.py from that page and did a find for PyShell.py, which found a lot of them. I don't know which one to patch (though I'm guessing not 2.5, since it says 2.6 in the shell) and I don't really know how to add the patched stuff in. I see a bunch of + + + + 's in the patch file, so I'm assuming there's an easy way to add this stuff in? A unix command? diff? /usr/share/pyshared/wx-2.6-gtk2-unicode/wx/py/PyShell.py/usr/lib/python2.5/idlelib/PyShell.py/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/py/PyShell.py/usr/lib/python2.6/idlelib/PyShell.py/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode/wx/py/PyShell.pyEdit: I think I'm wrecking havoc on my PyShell. I tried using the "patch" command, and only two of three "Hunks" succeeded, leaving one "Hunk' a failure. Hmm... It did actually fix two things that annoyed me, but code that failed to be patched was the up arrow key part. Looks like I'll have to put my newbie programming skills to the test and do this manually... look out. I sure hope making pong was adequate training for this.. :PEdit Again: Looks like finishing the patching by hand was extremely easy and it seems to work. Not sure why the command 'patch' didn't work 100%, but oh well. Thanks for finding the patch .

Edited by rob86 (see edit history)

Share this post


Link to post
Share on other sites

You know you could try Activepython 3 by activestate. Its basically the bees knees of IDE's for python. Though i cant say for sure what you get with the linux version, the windows v2 was very well refined and much more feature rich than the equivalent standard. It installed in a different location to the standard Python installation, not sure if it will do the same for linux. As far as im aware its free so long as you don't pick the Enterprise edition.

http://www.activestate.com/activepython-3

No problems about the patch hope it works well for you, python version 2.5 is good as well. Also if your interested (and if you dont already know) pyGame is an excellent addon for python that you could tryout. It utilizes SDL.

http://www.pygame.org/news.html

I was actually gonna enter in one of the competitions, but kinda got side tracked as usual.

Edited by inverse_bloom (see edit history)

Share this post


Link to post
Share on other sites

Is Activepython the same as ActiveState Komodo without the support for other languages? I downloaded the Komodo demo the other day when I was looking for IDE's but didn't try it yet. I'm interested in Pygame and will check it out. What's the difference between Pygame and Pyglet?

Share this post


Link to post
Share on other sites

ActivePython definitely is free if you don't go after Enterprise versions. I think Komodo does actually look like it has more features but maybe not applicable for your needs right now. To be honest that is the first time i had a close look at Pyglet, after having a quick look at the page Pyglet looks like it will give you simple tools but you will have to fill in the rest. With Pyglet you get the benefit of not having to install additional dependencies.

 

Pygame really rocks! Although you may end up dealing with a couple of additional dependencies which may need to installed from source (not sure). Pyweek is a competition held quarterly throughout the year, that's where you find the best games produced with Pygame. A link to some games are here - http://www.pygame.org/tags/pyweek

 

Although to run those games you definitely will have to install some additional dependencies like Numpy, Numeric... notes should be included within the archives to let you know what was used to produce the game and what you need. :P

Edited by inverse_bloom (see edit history)

Share this post


Link to post
Share on other sites

How difficult is it to make games like that with PyGame? I haven't been learning Python for very long. I'm almost done with the lessons here http://forums.xisto.com/no_longer_exists/ but considering it only took a couple days to go through it and understand it, I can't help but feel like there's a lot more to know before being able to make anything good like a game!

Share this post


Link to post
Share on other sites

It really depends, to be honest i was only showing those games to help you gauge what is possible with Pygame. If you think in terms of games like glactica and such, they are best if you follow a tutorial as you will get the experience you need to look at making your own games.

Experience is important because programing theory is relatively easy to understand at first glimpse. But in practice you'll find implementing the ideas you have is a totally different kettle of fish depending on problem complexity. The good thing is i can honestly say if you really want to make small games Pygame is one of the best options there is to have a go at first.

Pygame has much the same methodologies as Python does, which is to keep programmers away from dealing with lower level details. Its built over SDL, so where Python utilizes much of C to do its stuff, so does Pygame over SDL. SDL is kinda like a universal platform which utilizes hardware for multimedia rich apps. It's not exactly like OpenGL or DirectX, but sort of similar concept (it doesnt get as close to the hardware and so doesn't perform as they do).

If you think you might be a little more serious about programming in future, then a good path to go down might be learning Java. If you think you might be that way inclined i'd suggest looking here -

http://forums.xisto.com/no_longer_exists/
(if that link doesn't work - Introduction to computer science, stanford methodology)

Basically its a whole introductory university course othered online, the only catch is obviously you want get any assistance. Although i'm relatively unexperienced on the matter, i'd probably be inclined to say its one of the worlds best courses offered on learning introductory programming. It's professor is funny which gives you motivation to keep up with the lectures and the material is very well though out. (Although it will require 10 gigs of bandwidth to eventually get the whole course, spread out over 10-15 weeks).

You'll make a couple of games while also learning the ACM library. The ACM library is aimed at teaching Java to individuals in a less sophisticated manner, by generalizing the details (its a library that inherents from other libraries). Its kinda like Python and Pygame, but is a shortcut to getting into Java. Thats exactly what i did i basically hopped from Python/Pygame, did a little C++ up to recursion and pointers/references, then on to the stanford course.

The ACM library is kinda like Pygame but you'll have to set up Eclipse which if i remember correctly is a Java IDE (could be as easy as - extract, then click). Although you'll have to invest some time learning Eclipse. (It wont be as easy as pygame but could be more desirable in the end).

Edited by inverse_bloom (see edit history)

Share this post


Link to post
Share on other sites

I know I'm necromancing this thread, but it returned near the top of a google search for this very topic and I realized that this thread did not have the answer I was looking for.

 

You can use the command ctrl+p to go to the 'previous'. Pretty straight forward and you don't have to install any silly IDE changing things.

Share this post


Link to post
Share on other sites

I eventually found the answer to be "alt-p" for previous command and "alt-n" for next command. CTRL + P is print for me.

 

If this doesn't work, you can also go to "IDLE Preferences", "Keys" and look for the "history-next" and "history-previous" bindings.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.