__init__.py

T

Tina I

When looking at other peoples code (to learn from it) I keep seeing an
empty file named "__init__.py". What's the purpose of this?

Thanks
Tina
 
T

Tina I

Tina said:
When looking at other peoples code (to learn from it) I keep seeing an
empty file named "__init__.py". What's the purpose of this?

Thanks
Tina

Duh! Never mind... found it.
Kinda neat actually :)

T
 
J

Jorgen Grahn

Duh! Never mind... found it.
Kinda neat actually :)

/What/ was neat? It's polite in cases like this to explain what the
answer or solution was.

I have never seen an empty __init__.py, and I'd like to know what its
purpose could be.

BR,
/Jorgen
 
S

Steve Holden

Jorgen said:
/What/ was neat? It's polite in cases like this to explain what the
answer or solution was.

I have never seen an empty __init__.py, and I'd like to know what its
purpose could be.

BR,
/Jorgen
The presence of an __init__.py marks a directory as the root of a Python
package, which means other modules can be found in it. This allows you
to import names with multiple levels of dots, which are modules within
packages.

regards
Steve
 
T

Tina I

Jorgen said:
/What/ was neat? It's polite in cases like this to explain what the
answer or solution was.

I have never seen an empty __init__.py, and I'd like to know what its
purpose could be.

BR,
/Jorgen
Sorry, it was just that it was so easy to find right there in the
documentation. I had just missed it the first time around. So I kinda
assumed that since it was spelled out so well in the doc I was asking a
very stupid question.
But anyway, it can be found here:
http://www.python.org/doc/2.1.3/tut/node8.html#SECTION008400000000000000000

Tina
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top