

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is __init__.py in Python?
The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable. An example of the __init__.py file:
from math import sin from my_package import my_func
The above code ensures that the imported functions are available in the package's modules when it is imported as it is defined in the __init__.py file. You can read more about __init__.py at http://mikegrouchy.com/blog/2012/05/be-pythonic-__init__py.html
- Related Questions & Answers
- What is the difference between .py and .pyc files ?
- Init process on UNIX and Linux systems
- What is immutable in Python?
- What is @ operator in Python?
- What is iterweekdays() in python?
- What is itermonthdates() in python?
- What is itermonthdays2() in python?
- What is filter() in python?
- What is Tick in Python?
- What is TimeTuple in Python?
- What is Exception in Python?
- What is CGI in Python?
- What is Pandas in python?
- What is unexpected indent in Python?
- What is exception handling in Python?
Advertisements