What’s an __init__.py file?
It’s usually empty, though some times there’s some instructions in there that’s too high level for me right now.
Having an __init__.py file tells python to ‘see’ the directory it is in as a python module. Hence all packages (applications) will have an __init__.py file or several ones within each separate module .
Not having it, or having it in the wrong places will most likely throw an Unhandled Exception.
Q: If it’s empty anyway, can I just copy it into different directories?
I tried, and it doesn’t throw an error unless you copied it into a folder that isn’t meant to be a python module. Then you will get an Unhandled Exception shown in your browser.
Q: What about the pyc file that comes with it?
That woozy file __init__.pyc looks like this:
and is for computers to read. You can delete it (sometimes a .pyc file doesn’t update to reflect the changes in the py file and causes trouble), and a new .pyc file will be generated by your friend the computer when it next requires.