@@ -8,7 +8,15 @@ be stored in files.
8
8
9
9
If you use IDLE as your editor, it comes with everything set up for you
10
10
and you can get started right away. If you are going to use some other
11
- editor, you may need to set
11
+ editor, you may need to change some settings to make it suitable for
12
+ Python use.
13
+
14
+ Do ** not** use word processors like Microsoft Word and LibreOffice
15
+ Write for programming. They create their own files, but you need plain
16
+ text files for programming.
17
+
18
+ Start by creating an empty file called ` hello.py ` and opening it with
19
+ your editor. Or just open your editor and save a file as ` hello.py ` .
12
20
13
21
## Automatic tab expanding
14
22
@@ -17,17 +25,27 @@ and the official style guide tells you to never use tabs.
17
25
18
26
However, ** you don't need to press the spacebar four times every time
19
27
you want to indent** . Your editor should give you four spaces when you
20
- hit the tab key. Your editor should also remove four spaces when you
21
- hit backspace and there are four spaces before the cursor.
28
+ hit the tab key. Some editors also remove four spaces when you hit
29
+ backspace and there are four spaces before the cursor.
22
30
23
31
### Geany
24
32
25
- 1 . Create a file called ` hello.py ` , and open it in geany. Or create a
26
- file in geany and save it as ` hello.py ` .
27
- 2 . Go to Edit at the top and select Preferences.
28
- 3 . Go to Editor at left.
29
- 4 . Go to Indenting at top.
30
- 5 . Select spaces instead of tabs.
33
+ 1 . Go to * Edit* at the top and select Preferences.
34
+ 2 . Go to * Editor* at left.
35
+ 2 . Go to * Indenting* at top.
36
+ 4 . Select * Spaces* instead of * Tabs* .
37
+
38
+ ### gedit and pluma
39
+
40
+ 1 . Go to Edit at the top and select Preferences.
41
+ 2 . Go to Editor at top.
42
+ 3 . Change the indent width to 4 and select * Add spaces instead of tabs* .
43
+
44
+ ### Mousepad
45
+
46
+ 1 . Go to * Document* at the top, then * Tab Size* .
47
+ 2 . Select 4.
48
+ 3 . Also select * Insert Spaces* .
31
49
32
50
## Syntax highlighting
33
51
@@ -36,19 +54,64 @@ color than the rest of your text. `"Strings"`, `# comments` and
36
54
everything else should also have their own colors. This makes it much
37
55
easier to write code.
38
56
57
+ All the editors below have syntax highlighting by default, but you can
58
+ also change the colors if you don't like them.
59
+
39
60
### Geany
40
61
41
- Geany has syntax highlighting by default. You can also install more
42
- [ color schemes] ( https://www.geany.org/Download/Extras#colors ) if you
43
- don't like the default colorsm and change the color scheme by clicking
44
- View, then Change Color Scheme.
62
+ Install more [ color schemes] ( https://www.geany.org/Download/Extras#colors ) ,
63
+ then go to * View* , * Change Color Scheme* .
64
+
65
+ ### gedit and pluma
66
+
67
+ Click * Fonts & Colors* in the preferences and select another color
68
+ theme.
69
+
70
+ ### GNU Emacs
71
+
72
+ Type M-x, type ` load-theme ` , press Tab twice to see a list of theme
73
+ names, then enter a theme name and press Enter. If you want to
74
+ automatically change the theme when Emacs starts, add
75
+ ` (load-theme 'your-theme-name) ` to your ~ /.emacs file.
76
+
77
+ ### IDLE
45
78
46
- ## Plugins
79
+ Go to * Options * , then * Configure IDLE * , then * Highlighting * at top.
47
80
48
- Advanced editors support plugins. You may find some of them useful.
81
+ ## Is your editor using Python 3?
82
+
83
+ Some editors allow you to run your programs with a single keypress,
84
+ usually by pressing F5. This tutorial is written for Python 3 or newer,
85
+ so your editor also needs to run the programs in Python 3 or newer.
86
+
87
+ If you are unsure which Python your editor runs, create a test file
88
+ with the following contents:
89
+
90
+ ``` py
91
+ import sys
92
+ print (sys.version)
93
+ ```
94
+
95
+ If the version starts with 2, it's too old.
49
96
50
97
### Geany
51
98
52
- On Debian-based GNU/Linux distributions, install the geany-plugins
53
- package. See [ the Geany website] ( https://plugins.geany.org/ ) for
54
- instructions for other platforms.
99
+ 1 . Go to * Build* , then * Set Build Commands* .
100
+ 2 . Replace ` python ` or ` python2 ` with ` python3 ` everywhere.
101
+
102
+ ### GNU Emacs
103
+
104
+ Usually I write something in Emacs, then I press Ctrl+Z to suspend
105
+ Emacs and run the program myself. If you know how to run programs in
106
+ Emacs and you'd like to write about it here, [ tell me] ( contact-me.md ) .
107
+
108
+ ### IDLE
109
+
110
+ If you [ installed IDLE] ( installing-python.md ) correctly, it should use
111
+ Python 3.
112
+
113
+ ***
114
+
115
+ You may use this tutorial freely at your own risk. See [ LICENSE] ( LICENSE ) .
116
+
117
+ [ Back to the list of contents] ( README.md )
0 commit comments