Can anyone recommend a Python compiler/IDE?

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Rippy
Posts: 2101
Joined: Sun Jul 22, 2007 11:27 pm UTC
Location: Ontario, Can o' Duh

Can anyone recommend a Python compiler/IDE?

Postby Rippy » Mon Aug 06, 2007 3:56 pm UTC

I got really fed up trying to get C# and XNA working, since I don't have XP (which XNA requires), and I couldn't get direct3d working in a virtual machine of XP.

So, I've decided to take up Python and Pygame instead. I'm also posting this on my fresh Ubuntu install, re-installed about 10 minutes ago. I guess I'm trying to separate myself from Windows again :P

But what I'm wondering is, what's a good IDE/compiler for Python? One that I'd heard good things about was ActiveState's ActivePython, which is for PC Mac and Linux, but I never really got a chance to try it out.

Basically, I need something that works in Ubuntu, and was wondering if there are any Python programmers (or former ones) who'd have suggestions. Since I don't really have any idea what I'm looking for exactly, or what's to be desired in an IDE, etc.

Edit: btw I'm aware Ubuntu comes with one, but I'm also aware that sometimes there are better/cooler apps than Ubuntu's defaults :P
Last edited by Rippy on Mon Aug 06, 2007 4:03 pm UTC, edited 1 time in total.

User avatar
wraith
Posts: 103
Joined: Mon Aug 06, 2007 6:58 am UTC
Contact:

Postby wraith » Mon Aug 06, 2007 4:03 pm UTC

Python compiler ?
Did you mean an 'interpreter'?

(If you do, look at this (ides only): http://en.wikipedia.org/wiki/List_of_in ... for_Python )
It's only when you look at an ant through a magnifying glass on a sunny day that you realize how often they burst into flames

User avatar
Rippy
Posts: 2101
Joined: Sun Jul 22, 2007 11:27 pm UTC
Location: Ontario, Can o' Duh

Postby Rippy » Mon Aug 06, 2007 4:12 pm UTC

er, might've.

Basically, I want a nice little program that you can enter your code into, that tells you if you screwed something up, and that can turn the code into something you can execute.

Sorry, as you can see I'm not particularly familiar with the lingo, though I thought I had more of an idea of what I was talking about than I actually did. I have a firm grasp of what an IDE is, but "interpreter" and "compiler" are a bit hazier.

User avatar
wraith
Posts: 103
Joined: Mon Aug 06, 2007 6:58 am UTC
Contact:

Postby wraith » Mon Aug 06, 2007 4:31 pm UTC

I already gave you a list of nice little programs that you can enter code into. And they will tell you if you screwed something up. :)

As for the other thing. I'm sorry but you cannot turn Python code into something you can execute (well, technically there are some programs that try to do that, but they have limited functionality and in my opinion they're useless). Python is a scripting dynamic language. Python source cannot be turned into an executable file. It's always interpreted by an interpreter.

So an interpreter is something that can understand Python (or some other script language) programs and execute them. Without it, your programs are useless. A compiler, on the other hand, is a program that turns your compilable language source into a executable file. Once you get the executable, you don't need the compiler anymore, and you can execute it on other machines (Possibly it will require a similar platform. Few windows executables can be run on Linux)
It's only when you look at an ant through a magnifying glass on a sunny day that you realize how often they burst into flames

User avatar
djn
Posts: 610
Joined: Mon May 07, 2007 1:33 pm UTC
Location: Oslo, Norway

Postby djn » Mon Aug 06, 2007 4:35 pm UTC

A side effect is that python scripts are always distributed as source, and source only.

Oh, and they're compiled into .pyc files the first time the interpreter touches them, to speed things up, but that's a background process and everything would work without it happening.

User avatar
davean
Site Ninja
Posts: 2498
Joined: Sat Apr 08, 2006 7:50 am UTC
Contact:

Postby davean » Mon Aug 06, 2007 5:43 pm UTC

djn wrote:A side effect is that python scripts are always distributed as source, and source only.


py2exe? You can also distribute bytecode. Other methods exist.

User avatar
Rippy
Posts: 2101
Joined: Sun Jul 22, 2007 11:27 pm UTC
Location: Ontario, Can o' Duh

Postby Rippy » Mon Aug 06, 2007 6:37 pm UTC

^^^ http://pyinstaller.python-hosting.com/ There's another one, PyInstaller, that apparently works for Linux as well as Windows.

But anyway thanks for clearing this up, I didn't know this was the nature of Python. It's not that I don't want people to see the source (I'd include it anyway), but I just think it's better to have a good old non-modifiable executable. Particularly if you're sending it to people on Windows or on Linux distributions that somehow don't come with an interpreter.

I think I'll try figuring out how to use Ubuntu's default interpreter, and maybe try ActivePython if that doesn't work. Oh well, at least now I have more of an idea of what I'm doing.

User avatar
taggedunion
Posts: 146
Joined: Fri Jul 06, 2007 6:20 am UTC
Location: BEHIND YOU

Postby taggedunion » Mon Aug 06, 2007 8:30 pm UTC

IIRC, Ubuntu's "default interpreter" for Python is in fact the standard interpreter for Python: IDLE. Guido uses it, even (he's the one who invented Python, if you don't know). And from my experience, IDLE is a rather good interactive interpreter and will do just fine for checking the validity of expressions and such.

Most to all systems that have Python, whether by default or installed later, also have IDLE, so you can usually guarantee its presence if Python is already around. If there happens to be no IDLE, open up a terminal/command-line and type "python" and press Enter. Voila! The interactive interpreter sans syntax coloring. :)

Ubuntu has crappy defaults? Well, maybe GNOME has crappy defaults. Go to Aptitude or Synaptic and get KDE. Even if you still use GNOME as your display manager (like me), you get to have all the nice KDE programs hanging around. Oh, and for more fun and geek points, look for stuff on Aptitude/Synaptic before looking for stuff outside. The Debian family has a very excellent package manager system which makes installation and uninstallation very easy.

I wouldn't worry about a compiler / to-exe program for now. Get Python under your belt and learn how to use its present system of sources (and bytecode files) first.

Also, you needn't worry about portability except for on Windows. All of the major distros that I know something of (Red Hat, Debian/Ubuntu, Mandrake, SUSE...)* come with Python (and IDLE) in their default configurations. Mac OS X also comes with Python, too. In my experience, though, most of the programs you will be writing in Python you won't be wanting to port. ;P


(*) I know very little about some of the more arcane Linuces like Gentoo, but those are mostly for power users. The ones I mentioned are the major end-user-aimed Linuces and AFAIK have Python on the default install.
Yo tengo un gato en mis pantelones.

User avatar
Aglet
Posts: 364
Joined: Tue Mar 13, 2007 12:26 am UTC

Postby Aglet » Mon Aug 06, 2007 9:00 pm UTC

Since a good amount of important *nix programs ARE Python programs (foomatic, a lot of shell scripts, etc.), I think just about every single distribution on the face of the planet has Python. Therefore, in a Unix system, this is how to make a good ol' executable Python script. A Hello World program might look like this:

Code: Select all

#!/usr/bin/python

print "Hello, world!"


Note the "shebang" line at the beginning. That should be copied verbatim, unless your system has Python in a different place. After that, go to the directory your file is in in a terminal and type:

Code: Select all

chmod 755 hello.py


Obviously, substitute hello.py for whatever the file name is. Then to run it, just type:

Code: Select all

./hello.py


Do this in the directory the file is in, and your program should work like a charm.
Image

User avatar
taggedunion
Posts: 146
Joined: Fri Jul 06, 2007 6:20 am UTC
Location: BEHIND YOU

Postby taggedunion » Mon Aug 06, 2007 9:37 pm UTC

Indeed, indeed. I just didn't want to say "every" in case I was wrong. ;)
Yo tengo un gato en mis pantelones.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Postby EvanED » Mon Aug 06, 2007 11:44 pm UTC

I'm doing a little Python work, and decided to go with Eclipse. I've done next to nothing so far though. Eclipse was just my default choice because it's Java editing is outstanding, it has a pretty highly-regarded Python mode, and I didn't see anything that was noticeably better in my small search.

There very easily could be something better though.

iw
Posts: 150
Joined: Tue Jan 30, 2007 3:58 am UTC

Postby iw » Tue Aug 07, 2007 1:53 pm UTC

wraith wrote:As for the other thing. I'm sorry but you cannot turn Python code into something you can execute (well, technically there are some programs that try to do that, but they have limited functionality and in my opinion they're useless). Python is a scripting dynamic language. Python source cannot be turned into an executable file. It's always interpreted by an interpreter.

djn wrote:A side effect is that python scripts are always distributed as source, and source only.

I have some friends in a successful startup (shameless plug) that code their software in Python, and they get along just fine shipping software as bytecode and Windows executables using py2exe.

Dark Shikari
Posts: 113
Joined: Mon Jul 16, 2007 7:03 am UTC

Postby Dark Shikari » Tue Aug 07, 2007 6:56 pm UTC

iw wrote:
wraith wrote:As for the other thing. I'm sorry but you cannot turn Python code into something you can execute (well, technically there are some programs that try to do that, but they have limited functionality and in my opinion they're useless). Python is a scripting dynamic language. Python source cannot be turned into an executable file. It's always interpreted by an interpreter.

djn wrote:A side effect is that python scripts are always distributed as source, and source only.

I have some friends in a successful startup (shameless plug) that code their software in Python, and they get along just fine shipping software as bytecode and Windows executables using py2exe.

Another program whose client and server logic are both written in pure python

User avatar
Large Trout
Posts: 13
Joined: Tue Aug 07, 2007 6:49 pm UTC

Postby Large Trout » Tue Aug 07, 2007 7:40 pm UTC

Dark Shikari wrote:
iw wrote:
wraith wrote:As for the other thing. I'm sorry but you cannot turn Python code into something you can execute (well, technically there are some programs that try to do that, but they have limited functionality and in my opinion they're useless). Python is a scripting dynamic language. Python source cannot be turned into an executable file. It's always interpreted by an interpreter.

djn wrote:A side effect is that python scripts are always distributed as source, and source only.

I have some friends in a successful startup (shameless plug) that code their software in Python, and they get along just fine shipping software as bytecode and Windows executables using py2exe.

Another program whose client and server logic are both written in pure python


I'm pretty sure it's just EVE's interface (GUI) that's written in Python. The game engine itself was written in C++. Lots of games companies do this these days. I remember hearing that World of Warcraft's GUI is done in Python too.

I'm guessing they put a scripting interpreter somewhere in their C++ code that the Python can read from while running the game. I'm not a programming expert so, like I said, it's just a guess.

zenten
Posts: 3799
Joined: Fri Jun 22, 2007 7:42 am UTC
Location: Ottawa, Canada

Postby zenten » Tue Aug 07, 2007 7:59 pm UTC

You don't need source code to run Python (it can do everything at the bytecode level, just like Java), and there are programs that basically create an optimized interpreter for your optimized Python code, that runs as a single executable binary in Windows.

Dark Shikari
Posts: 113
Joined: Mon Jul 16, 2007 7:03 am UTC

Postby Dark Shikari » Tue Aug 07, 2007 10:16 pm UTC

Large Trout wrote:
Dark Shikari wrote:
iw wrote:
wraith wrote:As for the other thing. I'm sorry but you cannot turn Python code into something you can execute (well, technically there are some programs that try to do that, but they have limited functionality and in my opinion they're useless). Python is a scripting dynamic language. Python source cannot be turned into an executable file. It's always interpreted by an interpreter.

djn wrote:A side effect is that python scripts are always distributed as source, and source only.

I have some friends in a successful startup (shameless plug) that code their software in Python, and they get along just fine shipping software as bytecode and Windows executables using py2exe.

Another program whose client and server logic are both written in pure python


I'm pretty sure it's just EVE's interface (GUI) that's written in Python. The game engine itself was written in C++. Lots of games companies do this these days. I remember hearing that World of Warcraft's GUI is done in Python too.

I'm guessing they put a scripting interpreter somewhere in their C++ code that the Python can read from while running the game. I'm not a programming expert so, like I said, it's just a guess.

The engine itself (the graphics and such) is Visual C++ but all the game logic is Stackless Python which runs from compiled bytecode. The servers themselves are pure Stackless, at least nearly so.

User avatar
torne
Posts: 98
Joined: Wed Nov 01, 2006 11:58 am UTC
Location: London, UK

Postby torne » Wed Aug 08, 2007 9:47 am UTC

zenten wrote:You don't need source code to run Python (it can do everything at the bytecode level, just like Java), and there are programs that basically create an optimized interpreter for your optimized Python code, that runs as a single executable binary in Windows.

This doesn't protect your code very much, though, because it's trivial to decompile Python bytecode back to the source, and because Python is dynamic, you get all the variable/function names back too, even for local variables. The result is extremely close to the original source and highly human-readable (assuming your original source was, naturally).

py2exe is a convenient distribution method, not a way to hide your code.

zenten
Posts: 3799
Joined: Fri Jun 22, 2007 7:42 am UTC
Location: Ottawa, Canada

Postby zenten » Wed Aug 08, 2007 12:01 pm UTC

torne wrote:
zenten wrote:You don't need source code to run Python (it can do everything at the bytecode level, just like Java), and there are programs that basically create an optimized interpreter for your optimized Python code, that runs as a single executable binary in Windows.

This doesn't protect your code very much, though, because it's trivial to decompile Python bytecode back to the source, and because Python is dynamic, you get all the variable/function names back too, even for local variables. The result is extremely close to the original source and highly human-readable (assuming your original source was, naturally).

py2exe is a convenient distribution method, not a way to hide your code.


I didn't realize he was trying to hide his code, I thought he just didn't want people to have to bother with source code.

User avatar
WhiteRabbit
Railgun of Infinite Patience
Posts: 242
Joined: Fri Oct 20, 2006 2:30 pm UTC
Contact:

Postby WhiteRabbit » Wed Aug 08, 2007 2:55 pm UTC

At work I use python pretty regularly. To distribute apps we just use py2exe. I use SPE for my IDE. It works pretty well and has some nice wx support. It runs nicely on linux and windows, and mac support is coming along.
For the Jihad

User avatar
Rippy
Posts: 2101
Joined: Sun Jul 22, 2007 11:27 pm UTC
Location: Ontario, Can o' Duh

Postby Rippy » Wed Aug 08, 2007 4:04 pm UTC

Well, I got Eclipse with Pydev installed. I must say, Ubuntu's come a long way. On reinstalling I didn't have to do a thing to get video drivers working (well haven't tried any games yet, but compiz effects work better than ever before), and then I was able to get Eclipse, Pydev, and Pygame all through synaptic. :D The repository is getting quite extensive (or maybe it has been for a while and I just haven't noticed)

So anyway, I've read some tutorials and know the extreme basics. However, all the tutorials I found just go over data types one by one, etc. It's nice and in-depth, but I need to actually do some hands-on programming myself for it to sink in.

Anyone have any ideas for a simple first program? I'd prefer something a little more interesting than a basic calculator, but I guess I'll do that if all else fails. I just don't wanna jump into pygame straight away, not until I've made a coherent program at least.

User avatar
bavardage
Posts: 253
Joined: Sun Apr 15, 2007 11:38 pm UTC
Contact:

Postby bavardage » Wed Aug 08, 2007 4:18 pm UTC

Xkcd comic ripper?

Saves each comic as the number, with a seperate text file with number, title, caption.
'It can't be software incompatibility - the Trodden Spiral was designed for concentric rings, idiot ...'

User avatar
torne
Posts: 98
Joined: Wed Nov 01, 2006 11:58 am UTC
Location: London, UK

Postby torne » Wed Aug 08, 2007 4:32 pm UTC

zenten wrote:I didn't realize he was trying to hide his code, I thought he just didn't want people to have to bother with source code.

I may have misinterpreted, but still, it's true information :)

Comparing Python bytecode to JVM/CLR/etc bytecode is a bit off for that reason, simply because Python bytecode is much easier to turn back. Rereading, he doesn't care, so yah, py2exe is great.

User avatar
taggedunion
Posts: 146
Joined: Fri Jul 06, 2007 6:20 am UTC
Location: BEHIND YOU

Postby taggedunion » Wed Aug 08, 2007 8:49 pm UTC

Large Trout wrote:I remember hearing that World of Warcraft's GUI is done in Python too.


Really? I haven't heard anything of the sort. I know they use C++ for most everything and Lua to script the UI.

I'm guessing they put a scripting interpreter somewhere in their C++ code that the Python can read from while running the game. I'm not a programming expert so, like I said, it's just a guess.


It would be easier, IMO, to wrap the C++ and call it from Python (or whatever scripting language you're using) -- aka "extending". The other approach, "embedding", has to start a new interpreter for every call -- and with the Python interpreter, at least, that's quite expensive.
Yo tengo un gato en mis pantelones.

User avatar
Misanthrope
Posts: 16
Joined: Tue Aug 07, 2007 8:16 pm UTC
Location: United Kingdom

Postby Misanthrope » Fri Aug 10, 2007 12:15 am UTC

I found this while looking around in Wikipedia (I was trying to ascertain whether it would be worthwhile learning Python for myself). The website is a little odd; basically it's just a blogging site, but if you scroll down you'll eventually see a "Download" link on the right. I haven't checked it out for myself yet but I will do when I get around to learning some Python. Hope this helps the OP.

User avatar
thebeanie
Posts: 56
Joined: Mon Jun 11, 2007 10:13 am UTC
Location: Australia
Contact:

Postby thebeanie » Fri Aug 10, 2007 11:55 am UTC


User avatar
thebeanie
Posts: 56
Joined: Mon Jun 11, 2007 10:13 am UTC
Location: Australia
Contact:

Postby thebeanie » Fri Aug 10, 2007 12:00 pm UTC

Rippy wrote:Anyone have any ideas for a simple first program? I'd prefer something a little more interesting than a basic calculator, but I guess I'll do that if all else fails. I just don't wanna jump into pygame straight away, not until I've made a coherent program at least.


So you want a program, eh?
I started out with a geek code encoder, in which you had to answer questions and it printed out your geek code at the end.

Currently my projects include looking into web-based python development and rippers for webcomics.

If you want GUIs, mess around with Tkinter, or some of the python bindings like PyQt, PyGTK or whatever.

Honestly, do we python people have to prefix all our projects with "py"?

User avatar
djn
Posts: 610
Joined: Mon May 07, 2007 1:33 pm UTC
Location: Oslo, Norway

Postby djn » Fri Aug 10, 2007 1:22 pm UTC

I sort of like the py-naming. It makes it fairly obvious what they are, and easier to find and filter for.

And I retract my source-and-source-only comment above in the face of evidence. As it stands, I've only really downloaded python software on FreeBSD, and then getting the source instead of the binary is generally seen as a good thing. Thus, I've never been exposed to the alternatives. :)

User avatar
WhiteRabbit
Railgun of Infinite Patience
Posts: 242
Joined: Fri Oct 20, 2006 2:30 pm UTC
Contact:

Postby WhiteRabbit » Fri Aug 10, 2007 7:41 pm UTC

For GUIs I strongly recommend wxPython. It's very cross platform and uses native widgets where available so it always looks right.
For the Jihad

User avatar
musicinmybrain
Posts: 96
Joined: Sun Dec 31, 2006 2:50 am UTC
Location: Greensboro, NC

Postby musicinmybrain » Sat Aug 11, 2007 12:54 am UTC

WhiteRabbit wrote:For GUIs I strongly recommend wxPython. It's very cross platform and uses native widgets where available so it always looks right.


Seconded.
+ + + + + + + + [ > + + + + [ > + + > + + + > + + + > + < < < < - ] > + > - > + > > + [ < ] < - ] > > . > > - - - . + + + + + + + . . + + + . > . < < - . > . + + + . - - - - - - . - - - - - - - - . > + . > + + .

Gauss
Posts: 8
Joined: Thu Aug 02, 2007 1:51 pm UTC
Location: On the long arm of the milkyway
Contact:

Postby Gauss » Sun Aug 12, 2007 6:56 am UTC

musicinmybrain wrote:
WhiteRabbit wrote:For GUIs I strongly recommend wxPython. It's very cross platform and uses native widgets where available so it always looks right.


Seconded.


Agreed. The only downside is the wxPython libraries use around 12MBs on Windows :(. In OSX they're installed by default though :) so wxPython apps are very very small.
To iterate is human, to recurse, divine.

der_bAUer
Posts: 74
Joined: Wed Nov 01, 2006 9:55 am UTC

Postby der_bAUer » Sun Aug 12, 2007 10:03 am UTC

An interesting small first project is a program to generate funny nonsense sentences. Make some lists for subject, predicate, adverb, and place. Then use a random element of each list and string them together to form a sentence. Program it with for loops, then see how much shorter the code becomes after you replace those with list comprehensions ;)

User avatar
b.i.o
Green is the loneliest number
Posts: 2519
Joined: Fri Jul 27, 2007 4:38 pm UTC
Location: Hong Kong

Postby b.i.o » Sun Aug 12, 2007 4:16 pm UTC

For my first project I've made/am making a program to encrypt and decrypt text fragments based on a very simple algorithm. The encryption part has been quite easy. The part I'm not sure how to go about is the decryption. So if anyone could give a hint or two, that would be nice. (I don't want complete ideas, I'd like to figure out exactly how to write it myself.)

Anyway, what I'm doing for the encryption is setting the variables that are single letters to their number in the alphabet, and then putting the fragment I want encrypted in a string. I take the characters in the string out one at a time, use the eval() function to make them into their corresponding numbers (I made a few exceptions so it could detect punctuation and skip spaces), and then using the algorithm. It then prints the number I get out, and loops.

The problem I'm having is that I'm not sure how to do this in reverse, because while I can make the letters into numbers easily enough with eval(), I'm not sure how to make the numbers into letters. I know I could have if/elif statements detecting each individual number and translating them into letters, but there seems like there has to be a better way to do it. With what I'm doing now it would be an extra 50-something lines of code. With what I want to do, it would be an extra 800 lines of code at the very best--and while I can think of a couple ways to make it more efficient, it still feels like that would be the brute-force method of doing it, and that there has to be a much simpler way, especially since the method of encryption only requires somewhere around 10 lines of code.

User avatar
Torn Apart By Dingos
Posts: 817
Joined: Thu Aug 03, 2006 2:27 am UTC

Postby Torn Apart By Dingos » Sun Aug 12, 2007 4:39 pm UTC

Silver2Falcon: How are you using eval to turn characters into numbers? You should try to avoid using eval as much as possible. You can use the built-in functions ord and chr to convert characters to and from integers.

User avatar
b.i.o
Green is the loneliest number
Posts: 2519
Joined: Fri Jul 27, 2007 4:38 pm UTC
Location: Hong Kong

Postby b.i.o » Mon Aug 13, 2007 12:07 am UTC

Ah, ok, thanks :)

Didn't know those existed...

What I was doing was setting all the strings that were single letters to their equivalent number in the alphabet (a=1, b=1, etc.) and then once I had pulled the specific letter out of the fragment I was decoding, I would use eval on it to turn it into the number...this should work better.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 9 guests