Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
59380114
Commit
59380114
authored
Sep 07, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial revision
parent
f5f5fdbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
0 deletions
+98
-0
Doc/lib/libni.tex
Doc/lib/libni.tex
+49
-0
Doc/libni.tex
Doc/libni.tex
+49
-0
No files found.
Doc/lib/libni.tex
0 → 100644
View file @
59380114
\section
{
Built-in Module
\sectcode
{
ni
}}
\label
{
module-ni
}
\bimodindex
{
ni
}
The
\code
{
ni
}
module defines a new importing scheme, which supports
packages containing several Python modules. To enable package
support, execute
\code
{
import ni
}
before importing any packages. Importing
this module automatically installs the relevant import hooks. There
are no publicly-usable functions or variables in the
\code
{
ni
}
module.
To create a package named
\code
{
spam
}
containing sub-modules
\code
{
ham
}
,
\code
{
bacon
}
and
\code
{
eggs
}
, create a directory
\file
{
spam
}
somewhere on Python's module search
path, as given in
\code
{
sys.path
}
. Then, create files called
\file
{
ham.py
}
,
\file
{
bacon.py
}
and
\file
{
eggs.py
}
inside
\file
{
spam
}
.
To import module
\code
{
ham
}
from package
\code
{
spam
}
and use function
\code
{
hamneggs()
}
from that module, you can use any of the following
possibilities:
\bcode
\begin{verbatim}
import spam.ham # *not* "import spam" !!!
spam.ham.hamneggs()
\end{verbatim}
\ecode
%
\bcode
\begin{verbatim}
from spam import ham
ham.hamneggs()
\end{verbatim}
\ecode
%
\bcode
\begin{verbatim}
from spam.ham import hamneggs
hamneggs()
\end{verbatim}
\ecode
%
\code
{
import spam
}
creates an
empty package named
\code
{
spam
}
if one does not already exist, but it does
\emph
{
not
}
automatically import
\code
{
spam
}
's submodules.
The only submodule that is guaranteed to be imported is
\code
{
spam.
__
init
__}
, if it exists; it would be in a file named
\file
{__
init
__
.py
}
in the
\file
{
spam
}
directory. Note that
\code
{
spam.
__
init
__}
is a submodule of package spam. It can refer to
spam's namespace as
\code
{__}
(two underscores):
\bcode
\begin{verbatim}
__
.spam
_
inited = 1 # Set a package-level variable
\end{verbatim}
\ecode
%
Additional initialization code (setting up variables, importing other
submodules) can be performed in
\file
{
spam/
__
init
__
.py
}
.
Doc/libni.tex
0 → 100644
View file @
59380114
\section
{
Built-in Module
\sectcode
{
ni
}}
\label
{
module-ni
}
\bimodindex
{
ni
}
The
\code
{
ni
}
module defines a new importing scheme, which supports
packages containing several Python modules. To enable package
support, execute
\code
{
import ni
}
before importing any packages. Importing
this module automatically installs the relevant import hooks. There
are no publicly-usable functions or variables in the
\code
{
ni
}
module.
To create a package named
\code
{
spam
}
containing sub-modules
\code
{
ham
}
,
\code
{
bacon
}
and
\code
{
eggs
}
, create a directory
\file
{
spam
}
somewhere on Python's module search
path, as given in
\code
{
sys.path
}
. Then, create files called
\file
{
ham.py
}
,
\file
{
bacon.py
}
and
\file
{
eggs.py
}
inside
\file
{
spam
}
.
To import module
\code
{
ham
}
from package
\code
{
spam
}
and use function
\code
{
hamneggs()
}
from that module, you can use any of the following
possibilities:
\bcode
\begin{verbatim}
import spam.ham # *not* "import spam" !!!
spam.ham.hamneggs()
\end{verbatim}
\ecode
%
\bcode
\begin{verbatim}
from spam import ham
ham.hamneggs()
\end{verbatim}
\ecode
%
\bcode
\begin{verbatim}
from spam.ham import hamneggs
hamneggs()
\end{verbatim}
\ecode
%
\code
{
import spam
}
creates an
empty package named
\code
{
spam
}
if one does not already exist, but it does
\emph
{
not
}
automatically import
\code
{
spam
}
's submodules.
The only submodule that is guaranteed to be imported is
\code
{
spam.
__
init
__}
, if it exists; it would be in a file named
\file
{__
init
__
.py
}
in the
\file
{
spam
}
directory. Note that
\code
{
spam.
__
init
__}
is a submodule of package spam. It can refer to
spam's namespace as
\code
{__}
(two underscores):
\bcode
\begin{verbatim}
__
.spam
_
inited = 1 # Set a package-level variable
\end{verbatim}
\ecode
%
Additional initialization code (setting up variables, importing other
submodules) can be performed in
\file
{
spam/
__
init
__
.py
}
.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment