Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 73164bc

Browse files
Merge pull request #8 from digitronik/fix___name__example
fix example
2 parents 6a38584 + d085cf5 commit 73164bc

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

‎file_and_modules.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,8 @@ Executing the else clause.
113113
## Writting a simple CIL script
114114
* We write scripts in order to reuse it multiple times.
115115
* In python you see '__' double underscore aka dunder.
116-
* Create a script greetings.py
116+
* Create a script greetings.py and fun.py
117117
```
118-
[raukadah@ironman python-workshop]$ python3 fun.py
119-
Welcome FOSS MEET
120-
the value of __name__ is greetings
121118
[raukadah@ironman python-workshop]$ cat greetings.py
122119
#!/usr/bin/python3
123120
import sys
@@ -129,14 +126,21 @@ def greeting(name):
129126
if __name__ == "__main__":
130127
name = "Chandan Kumar"
131128
greeting(name)
129+
130+
[raukadah@ironman python-workshop]$ python3 greeting.py
131+
Welcome Chandan Kumar
132+
the value of __name__ is __main__
133+
```
134+
```
132135
[raukadah@ironman python-workshop]$ cat fun.py
133136
#!/usr/bin/python3
134137
135138
import greetings
136139
137140
greetings.greeting('FOSS MEET')
141+
138142
[raukadah@ironman python-workshop]$ python3 fun.py
139143
Welcome FOSS MEET
140144
the value of __name__ is greetings
141-
[raukadah@ironman python-workshop]$
142-
```
145+
```
146+
* Observe meaning of `__name__` and `__main__`.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /