Newer
Older
# APPI 3
## Introduction
This is a repository for the APPI3 autumn semester course.
- _bold text_
- _italic text_
1. Enumerated lists
2. Enumerated item 2
3. Asdf
## if __name__ == `'__main__'` explained:
In Python, `__name__ == '__main__'` is used to determine whether a script is being run directly or being imported as a module.
When a Python file is run directly, the special variable `__name__` is set to `'__main__'`. So, `if __name__ == '__main__':` allows the code under this condition to run only when the file is executed directly, not when it is imported as a module.
This is useful when you want to have some code in your script that tests the functionality of the script but you don't want that code to run when the script is imported as a module.
Here's an example:
```python
def my_function():
return "Hello, World!"
if __name__ == '__main__':
# This code will only run if the script is run directly
print(my_function())
```
In this example, if you were to import this script as a module in another script with `import my_script`, the `print(my_function())` line would not execute. But if you run the script directly with `python my_script.py`, it will execute.