Bruno Raljić

A Java Developer's Blog

What IDE to use for Python?

Few weeks ago, I’ve decided to join the free online MongoDB course together with my colleagues. The whole NoSQL idea is totally new for me and I wondered how it looks like and where can it be applied in the real world situations. As I said, we found a free online course at education.10gen.com. Another new thing for me – the guys from 10gen selected Python as a preferred language during the course, and all the examples are written in Python. Of course, you can use whatever language you want, but it was OK with me to use Python, since we are not going to develop some complicated stuff (and also to learn a bit about Python syntax).

Why do I need an IDE?

At first, I used Notepad++ because it has support for Python syntax and I thought it will be enough. To be honest, I don’t like the whole thing with indentations in Python and I had a funny feeling about that. I’m coming from the world where you put your code block between { and }, but OK, I thought there won’t be a problems with that. Then I met Mr. IndentationError. First reaction was – “OK, I know, you have to watch out for indentation, let me just check this code…”, but there was no problem with indentation. From my point of view. I run the .py file again and again, getting same error. I literally stared in the simple piece of code, without any idea what could possibly be wrong. Soon I’ve found there are two ways to indent the code and you’re not allowed to mix them
If you are using spaces to indent code block, use it whole time, don’t mix it with tabs and vice verse.

Since the guys from 10gen are providing a lot of Python code, and they use space bar indentation, I end up with mixing it with tab indentation almost all the time. When I caught myself hitting space bar 12 times to indent something, I knew I’m ready for some Python IDE. Maybe I could set up this in Notepad++ but I also wanted something to store all my project files related to this course in one place.

Aptana to the rescue 

Short note at the very beginning, I don’t claim Aptana is the best solution, and I must admit I didn’t check others, but for now it gives me everything I need. A colleague of mine would say Ninja is better. You can check it out too.
 

“The professional, open source development tool for the open web”
As you see, you can download it as the Eclipse plugin or as a standalone version. I took standalone version (less configuration, in my opinion). So I created a new project for this MongoDB course and I plan to keep all the lesson files in it.
Creating new Python project
Note: Sometimes you can’t add new Python project until you set up a Python Interpreter. You can set it in preferences.
In most cases, clicking the “Auto Config” button will do the work, give it a try
Aptana supports about 30 color themes (find the button up in the toolbar) so if you don’t like the dark one that comes with installation, you can change it. Personally, I don’t like dark themes, so I changed it to bright one. 
Now you have:
  • syntax highlighting (OK, no big deal)
  • better overview (methods, variables…)
  • auto-complete
  • compilation errors, warnings
  • proper indentation  
OK, this is a very basic functionality of all IDEs, but as I said, it’s more than enough for my needs at this moment. Now I can forget about tabs, because every tab is automatically converted into appropriate number of spaces.

Terminals

This is, for sure, very helpful for this MongoDB course, because now you have all the things you need in one place. Taking in the consideration that you can end up with multiple command prompt windows, and it can be very messy, you’ll like the fact that you can run all this from Aptana and have all in one place. 

As you can see, you are not limited to one Terminal
You’ll for sure have mongod in one terminal, mongo in second, perhaps some mongo importing in third etc. Right now I don’t know how to set up default terminal start up (for example to run mongod in first terminal when I run Aptana), but I’ll update this if I find it out.

Conclusion

  • For a Python beginner like me, every help is welcome including syntax highlighting, auto-complete, compiler warnings, it really saves me a lot of time, there are no more unnecessary staring at the code and wondering what’s wrong. 
  • Another thing, I wanted to keep all lesson files and examples in one place
  • Mixing tab and space bar indentations are now past
  • Everything I need for the course is now in one place, including terminals
I’m sure there are more cool options Aptana has to offer, but for now, this is more than enough.


, , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Show my latest blog post with this comment!