Technical discussions | Discussions techniques
Subscription date : 02 September 2009
Messages : 539
|
bon, j'étudie python ( ainsi fabounet rallera plus sur mon Perl d'amour ;D )
j ai pu voir que :
a = 5
if a >= 2:
if a <= 8:
print("a est dans l'intervalle.")
else:
print("a n'est pas dans l'intervalle.")
else:
print("a n'est pas dans l'intervalle.")
bon je sais qu on peut coder ca avec un and,
mais ma question ; comment python connait la fin de la boucle, pas de endif ou de { } delimitant.
cordialement
--------------
Aujourd'hui, j'étais dans une fête foraine, dans un labyrinthe avec des glaces. Mon pote a trouvé la sortie en deux minutes, moi je ne l'ai jamais trouvée. Au bout de vingt minutes, j'ai dû suivre un gamin de dix ans pour sortir. Pendant tout ce temps, une dizaine de personnes m'observaient, hilares. VDM |
Subscription date : 05 August 2009
Messages : 285
|
Python can identify blocks by the indentation, it is mandatory in Python, i.e., or you indent it as Guido said, or it is going to return you the famous "Python: IndentationError: expected an indented block"
Try to run this script the way it is, and you are going to see the error by yourself.
Tip, normally 4 spaces are used to indent the code. On the PEP describing the indentation the first phrase you are going to see is:
"Use 4 spaces per indentation level. For really old code that you don't want to mess up, you can continue to use 8-space tabs." |
Subscription date : 02 September 2009
Messages : 539
|
oh ok,
thanks
i used TAB for indentation and that work  |
ppmt, Thursday 17 May 2012 à 15:34
|
|
Subscription date : 29 November 2007
Messages : 3520
|
4 spaces is the pythonic way I believe. The problem with tab is that it can change from one computer to another.
But whatever you choose keep using them across your program or it will also break as well. |
Subscription date : 02 September 2009
Messages : 539
|
ok, i will use 4 spaces
thank you
------
Aujourd'hui, alors que je m'apprête à coucher avec une rencontre d'un soir, je lui dis que je ne fais pas l'amour sans rien. Il se jette sur son portefeuille et me tend un billet de vingt euros. Je parlais du préservatif. VDM |
matttbe, Thursday 17 May 2012 à 19:03
|
|
Subscription date : 24 January 2009
Messages : 12573
|
But you can also use tab just as all the source code of Cairo-Dock (core, plug-ins and most third-party applets)  |
Subscription date : 30 November 2007
Messages : 17118
|
tab is the good way (no matter what some people may say ) because you can then set a tab to any number of spaces in your editor.
for instance I like 6 spaces, some might like 2 spaces.
but tabs should never be used inside a line (to align some piece of text for instance), only at the beginning. |
ppmt, Tuesday 22 May 2012 à 17:43
|
|
Subscription date : 02 September 2009
Messages : 539
|
hi,
what programs do you use to python ?
i use Scite for Perl, but i want to know what you use, maybe another is most good for python...
---------
Aujourd'hui, au bout d'une bonne demi-heure, je me suis aperçue que ce n'était pas mon chat que je câlinais de l'autre côté du fauteuil, mais bien un de mes nouveaux après-skis à poils. VDM |
matttbe, Wednesday 23 May 2012 à 09:14
|
|
ppmt, Wednesday 23 May 2012 à 17:05
|
|
Subscription date : 29 November 2007
Messages : 3520
|
vim with syntax on
I have seen Eric as well and heard good things about it but never used it. I never really understood the point of IDE (probably a problem with me rather than the IDE thouhgh )
http://eric-ide.python-projects.org/ |
Subscription date : 02 September 2009
Messages : 539
|
re,
j'avais deja essayé geany pour Perl, mais je suis revenu à Scite, je vais tester Eric
-----------------
Aujourd’hui, mon patron et le big boss me convoquent pour me parler de ma dépendance à la drogue, car j’arrive tous les jours avec les yeux tout rouges. Oui, voilà, c'est ça, je suis accro au chlore et tous les matins, je vais à la piscine avant ma journée de travail pour sniffer l'eau. VDM |
Subscription date : 05 August 2009
Messages : 285
|
I am using Gedit with a simple auto completion plugin. |
ppmt, Thursday 31 May 2012 à 15:47
|
|
Subscription date : 29 November 2007
Messages : 3520
|
I copied the plugin as indicated but it doesn't work for me... I can't see it in the plugins list
using ubuntu 11.10 |
matttbe, Thursday 31 May 2012 à 15:54
|
|
Subscription date : 24 January 2009
Messages : 12573
|
I guess you're using Gedit3.
Gnome.org : Howto install plugins
Copy files to .local/share/gedit/plugins/ or /usr/lib/gedit/plugins/, if you want a system wide install. |
ppmt, Friday 01 June 2012 à 16:21
|
|
Subscription date : 29 November 2007
Messages : 3520
|
Yes I had seen that as well but it still doesn't work.
you don't need to reboot, do you? |
matttbe, Friday 01 June 2012 à 17:25
|
|
Subscription date : 24 January 2009
Messages : 12573
|
Just restart Gedit but I guess old plugins for Gedit 2 have to be ported to use the new API. |
ppmt, Friday 01 June 2012 à 20:44
|
|
Subscription date : 29 November 2007
Messages : 3520
|
ah ok that could be it. |
Technical discussions | Discussions techniques
|