Skip to content

Commit e28cef7

Browse files
committed
Changed examples to mimic article and added default and pythonic pylint config files
1 parent d696763 commit e28cef7

5 files changed

Lines changed: 73 additions & 11 deletions

File tree

‎.pylintrc_default‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[MASTER]
2+
3+
#init-hook='import sys; import os; sys.path.append(os.getcwd() + "/example/hello_world")'
4+
5+
6+
7+
[MESSAGES CONTROL]
8+
9+
#disable=superfluous-parens,anomalous-backslash-in-string,bad-builtin,invalid-name
10+
disable=W0105,W0141,C0103,R0903,F0401,R0912,R0914,R0915,E0611,E1101,E1103,W0122,C0303,broad-except,global-statement,too-many-instance-attributes,no-self-use,superfluous-parens,locally-disabled,locally-enabled
11+
12+
13+
14+
[FORMAT]
15+
16+
# Maximum number of characters on a single line.
17+
max-line-length=120
18+
19+
# Maximum number of lines in a module
20+
#max-module-lines=1000
21+
max-module-lines=5000
22+
23+
24+
[REPORTS]
25+
26+
reports=no
27+
#include-ids=yes

‎.pylintrc_pythonic‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[MESSAGES CONTROL]
2+
3+
disable=locally-disabled,locally-enabled
4+
5+
6+
[FORMAT]
7+
8+
# Maximum number of characters on a single line.
9+
max-line-length=79
10+
11+
12+
[REPORTS]
13+
14+
#reports=no

‎example/flow/for.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
"""
5+
Example script showing usage of for-loop for article
6+
Villkor och loopar
7+
"""
8+
49
for i in range(10):
510
print(i)
611

712

8-
for i in range(10):
9-
number = i + 1
10-
if number > 5:
11-
print("Stor")
13+
for number_of_apples in range(13):
14+
if number_of_apples > 10:
15+
print("Du har mer än 10 äpplen")
16+
elif number_of_apples <= 10 and number_of_apples > 5:
17+
print("Du blev snabbt mätt och åt bara upp några av dina äpplen")
1218
else:
13-
print("Liten")
19+
print("Du har nog varit hungrig och ätit upp dina äpplen")
1420

1521

1622
for _ in range(5):

‎example/flow/if.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
"""
5+
Example script showing usage of if-statements for article
6+
Villkor och loopar
7+
"""
8+
9+
410
number_of_apples = 13
511

612
if number_of_apples > 10:

‎example/flow/while.py‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
"""
5+
Example script showing usage of while-loop for article
6+
Villkor och loopar
7+
"""
8+
49
number = 2
510

611
while number < 20:
712
print(number)
813
number = number + number
914

1015

11-
mega_sum = 0
12-
1316
while True:
14-
user_input = input("Skriv in en siffra (eller q för avslut): ")
17+
user_input = input("Skriv in antal äpplen (eller q för avslut): ")
1518
if user_input == "q":
16-
print("MegaSum: " + str(mega_sum))
19+
print("Du är nu klar med att äta äpplen.")
20+
print("Hej då!")
1721
break
1822
else:
19-
number = int(user_input)
20-
mega_sum += number
23+
number_of_apples = int(user_input)
24+
if number_of_apples > 10:
25+
print("Du har mer än 10 äpplen")
26+
elif number_of_apples <= 10 and number_of_apples > 5:
27+
print("Du blev snabbt mätt och åt bara upp några av dina äpplen")
28+
else:
29+
print("Du har nog varit hungrig och ätit upp dina äpplen")

0 commit comments

Comments
 (0)