Outils pour utilisateurs

Outils du site


issue135:python

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.

Quand je rencontre un autre programmeur pour la première fois, il me demande habituellement les langages que j'utilise pour écrire mes programmes. Généralement, en deuxième lieu, il demande dans quel logiciel j'écris mon code : dans Emacs, VIM, un éditeur de texte ou un EDI (environnement de développeur intégré). Je surprends la plupart des programmeurs avec ma réponse : Geany.

Une des choses qui rendent (et gardent) un programmeur productif est un EDI efficace. Depuis des années, j'essaie beaucoup d'applications EDI et d'éditeurs de code différents, et je reviens toujours à Geany. Bien que Geany ne soit pas « officiellement » un EDI, il fait le travail, puisqu'il vous permet d'écrire du code et d'appeler un processus de compilation (pour des langages comme C/C++).

Au premier regard, ce n'est pas très tape-à-l'œil, mais plutôt austère et terne. Cependant, quand vous commencez à travailler avec, le manque d'une apparence tapageuse n'est pas une mauvaise chose. Avec une exception, Geany a tout ce qu'un programmeur en Python (ou la plupart des autres programmeurs) voudrait. Cette seule exception, c'est le débogage, ce qui n'est pas si grave que ça, pour ce qui me concerne.

Examinons Geany en détail.

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.

Comme tout EDI moderne, Geany comporte de multiples onglets d'éditeur, ce qui rend facile le traitement de la plupart des gros projets. Il offre aussi le support pour des fenêtres divisées, soit côte-à-côte, soit empilées.

Ainsi, il est très facile pour moi de voir la définition d'une fonction pour laquelle je crée un appel, car je peux connaître tous les paramètres que je dois fournir et leur ordre.

Un des éléments qui me plaisent le plus chez Geany est la barre latérale « symbols ».

Celle-ci montre toutes les fonctions du programme actuel ainsi que le numéro de la ligne où elles sont définies. À nouveau, pour moi c'est un aide-mémoire fantastique.

Bien entendu, Geany propose aussi des thèmes, de très sombre à très clair et à peu près tout ce qu'il y a entre les deux, avec plus de 30 thèmes prédéfinis différents. Ils sont disponibles sous forme de paquets d'extension.

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.

Une autre chose que pas mal d'EDI fournissent de nos jours est le support des extraits de code, ce sont des petits bouts de code pré-établis qui peuvent être insérés en tapant un mot-clé, puis en appuyant sur la touche Tab. En haut à droite, se trouve un exemple de quelques extraits de code prédéfinis.

Ainsi, si vous vouliez démarrer une boucle for en Python, tout ce qu'il faut faire est de taper :

for

…puis appuyez sur la touche Tab (avant de taper l'espace après) et vous aurez :

for i in xrange(_):

… avec le curseur à l'intérieur des parenthèses qui attend que vous complétiez la ligne. Ceci fonctionne aussi avec des blocs de lignes multiples. Puisque j'aime « décorer » mon code avec beaucoup de commentaires, j'en ai paramétré un que j'appelle « boîte ». Quand je l'utilise, Geany insère :

#

# _ #

Il me suffit de remplir l'espace avec ce dont j'ai besoin à ce moment précis.

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.

Bien entendu, puisque Geany gère de multiples langages de programmation, les extraits de code dépendent du langage ; aussi il faut, soit sauvegarder le fichier comme un fichier « .py » avant d'utiliser la fonctionnalité des extraits de code, soit utiliser l'option du menu Document|Définir le type de fichier|Langage de script|Fichier source Python.

Geany fourmille de raccourcis claviers qui correspondent à beaucoup de mes méthodes de travail. Pendant que je suis au milieu d'un programme, je décide parfois d'ajouter quelque chose auquel je n'avais pas pensé quand j'ai fait la conception initialement. Plusieurs fois, par exemple, je décide à mi-chemin d'entourer un bloc de code avec un Try|Except, ce qui nécessite que le code existant soit indenté. Le bloc est indenté avec un simple <ctrl>I et, si je change d'avis, un <ctrl>U (U pour unindent) le désindentera. Commenter des blocs de code est tout aussi simple : <ctrl>E commentera un bloc de code et, au besoin, enlèvera le commentaire aussi.

Un autre truc génial chez Geany est que je peux lancer mon code directement à partir de l'éditeur en cliquant sur l'icône « Exécuter » ou en appuyant sur <F5>. Actuellement, par défaut, je l'ai configuré pour utiliser Python 2.x. Si je veux que ce soit sous Python 3.x, il me suffit d'utiliser les options du menu Construire et de sélectionner l'option que j'ai paramétrée pour l'utilisation de Python 3. Encore une fois, beaucoup d'éditeurs/EDI permettent ceci.

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.

Oui, il est vrai que beaucoup des meilleurs EDI modernes proposent la plupart, pour ne pas dire l'intégralité, des fonctionnalités que j'ai présentées ici, mais je trouve qu'il est plus facile de les déployer avec Geany quand j'en ai besoin. Qui plus est, Geany est gratuit, disponible pour la plupart des systèmes d'exploitation et est Open Source ; je peux être productif sous n'importe quel environnement que j'utilise. Veuillez comprendre que tous mes commentaires reflètent mes propres opinions et concernent uniquement mes préférences.

À la prochaine fois ; passez un excellent mois.

issue135/python.txt · Dernière modification : 2018/08/13 14:53 de christo.2so