Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions students/uss_tomasz/lesson_00_the_setup/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

"""This is an example module to teach you about git and PyCharm use.

Python supports many ways to write programs. You can start with a very simple
imperative code, like this script.
"""

print("Hello world!")

#!/usr/bin/env python3

"""The `hello_world.py` approach is good for simple scripts, where the code is
unlikely to be reused.

As soon as you want to import and use your code from other modules, you want
to make sure it runs only when asked to. To do that we check magic variable
__name__, set by the interpreter. If the script has been called directly,
the variable holds '__main__' string.
"""


def main():
print('Hello world!')


if __name__ == '__main__':
# `python hello_world.py` will run main(), `import hello_world` will not
main()

# `import hello_world` will still allow me to run `hello_world.main()`