Outils pour utilisateurs

Outils du site


issue135:python

Ceci est une ancienne révision du document !


When I meet another programmer for the first time, the first question that they usually ask is what languages do I program in. Their second question is usually what do I write my code in. Is it Emacs, VIM, a text editor, or an IDE. I surprise most programmers with my answer of Geany.

One of the things that makes (and keeps) a programmer productive is an efficient IDE. Over the years, I've tried many different IDE applications and code editors, and I always come back to Geany. While Geany is not “officially” an IDE, it does the job, since it allows you to write code, and call a build process (for languages like C/C++).

It’s not flashy at first glance, but rather stark and bland. But once you start working with it, the lack of flashy is not a bad thing. With one exception, Geany has everything that a Python programmer (or most other programmers) would want. That one exception is debugging, which isn't really that big of an issue for me.

Let's take a look at Geany in depth.

Like any modern IDE, Geany has multiple editor tabs, which makes it easy to deal with most large projects. It also has support for split windows, either side-by-side or stacked.

This makes it very easy for me to see the definition of a function that I’m writing a call to, so that I know all of the parameters that I need to provide and in what order.

One of the things that I like most about Geany is the 'symbols' sidebar.

This shows all of the functions that are in the current program, as well as the line number on which they are defined. Again, for me, this is a fantastic memory aid.

Of course, Geany also has themes, from dark to light and pretty much anywhere in between, with over 30 different themes pre-defined. These are available as an add-on package.

Another thing that many IDEs provide these days is snippet support, which are bits of preset code that can be inserted by typing a keyword and then pressing the <Tab> key. Shown top right is an example of some of the predefined snippets…

So, if you wanted to start a for loop in Python, all you have to do is type:

for

…then hit the tab key (before typing the space after) and you get:

for i in xrange(_):

…with the cursor inside the parens waiting for you to flesh out the line. This works also with multiline blocks. Since I like to “decorate” my code with lots of comments, I set up one that I call ‘box’. When I use it, Geany puts in:

#

# _ #

I can just fill in the blank with whatever I need at the time.

Of course, since Geany handles multiple programming languages, the snippets are language dependant, so you have to either save the file as a ‘.py’ file before you can use the snippet feature, or you can use the menu option Document|Set Filetype|Scripting Languages|Python source file.

Keyboard shortcuts abound that take care of many of my work methods. As I’m programming away, sometimes I decide to add something that I wasn’t planning on when I did the original design. Many times, for example, I decide in midstream to add a Try|Except around a block of code. This requires the existing code to be indented. A simple <Ctrl>I indents the block and if I change my mind, a <Ctrl>U will unindent it. Commenting blocks of code is just as simple, using <Ctrl>E which will both comment and uncomment the code block.

Another wonderful thing about Geany is that I can run my code directly from the Editor by clicking on the ‘Run’ icon, or by pressing <F5>. By default, right now, I’ve got it set to use Python 2.x. If I want to run under Python 3.x, I simply use the Build menu options and select the option I’ve got set up for using Python 3. Again, many editors/IDEs allow for this.

Yes, many of the better modern IDEs have most, if not all, of the features I’ve outlined here, but I find that Geany is easier to deploy them when I need them. Add the fact that Geany is Free, available for most operating systems, and is open source; I can be productive under whatever environment I’m using. Please take all of my comments as my own opinions and pertain to only my preferences.

Until next time, have a great month.

issue135/python.1533133427.txt.gz · Dernière modification : 2018/08/01 16:23 de auntiee