Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9a4e3fc5
Kaydet (Commit)
9a4e3fc5
authored
Eyl 03, 1992
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Changed references to /usr/local into /usr/local/bin.
Documented $PYTHONSTARTUP
üst
2dff991f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
18 deletions
+62
-18
tut.tex
Doc/tut.tex
+31
-9
tut.tex
Doc/tut/tut.tex
+31
-9
No files found.
Doc/tut.tex
Dosyayı görüntüle @
9a4e3fc5
...
...
@@ -147,8 +147,8 @@ modules that can save you a lot of time when writing Python programs.
\section
{
Invoking the Interpreter
}
The Python interpreter is usually installed as
{
\tt
/usr/local/python
}
on those machines where it is available; putting
{
\tt
/usr/local
}
in
The Python interpreter is usually installed as
{
\tt
/usr/local/
bin/
python
}
on those machines where it is available; putting
{
\tt
/usr/local
/bin
}
in
your
{
\UNIX
}
shell's search path makes it possible to start it by
typing the command
...
...
@@ -159,7 +159,7 @@ python
to the shell. Since the choice of the directory where the interpreter
lives is an installation option, other places are possible; check with
your local Python guru or system administrator. (E.g.,
{
\tt
/usr/local/
bin/
python
}
is a popular alternative location.)
/usr/local/python
}
is a popular alternative location.)
The interpreter operates somewhat like the
{
\UNIX
}
shell: when called
with standard input connected to a tty device, it reads and executes
...
...
@@ -211,7 +211,7 @@ and a copyright notice before printing the first prompt, e.g.:
\bcode
\begin{verbatim}
python
Python 0.9.
5 (Jan 2
1992).
Python 0.9.
7 (Aug 28
1992).
Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam
>>>
\end{verbatim}
\ecode
...
...
@@ -248,12 +248,12 @@ When a module named {\tt foo} is imported, the interpreter searches
for a file named
{
\tt
foo.py
}
in the list of directories specified by
the environment variable
{
\tt
PYTHONPATH
}
. It has the same syntax as
the
{
\UNIX
}
shell variable
{
\tt
PATH
}
, i.e., a list of colon-separated
directory names. When
{
\tt
PYTHONPATH
}
is not set,
an
i
nstallation-dependent default path is used, usually
{
\t
t
.:/usr/local/lib/python
}
.
directory names. When
{
\tt
PYTHONPATH
}
is not set,
or when the file
i
s not found there, the search continues in an installation-dependen
t
default path, usually
{
\tt
.:/usr/local/lib/python
}
.
Actually, modules are searched in the list of directories given by the
variable
{
\tt
sys.path
}
which is initialized from
{
\tt
PYTHONPATH
}
or
variable
{
\tt
sys.path
}
which is initialized from
{
\tt
PYTHONPATH
}
and
the installation-dependent default. This allows Python programs that
know what they're doing to modify or replace the module search path.
See the section on Standard Modules later.
...
...
@@ -280,13 +280,35 @@ On BSD'ish {\UNIX} systems, Python scripts can be made directly
executable, like shell scripts, by putting the line
\bcode
\begin{verbatim}
#! /usr/local/python
#! /usr/local/
bin/
python
\end{verbatim}
\ecode
%
(assuming that's the name of the interpreter) at the beginning of the
script and giving the file an executable mode. The
{
\tt
\#
!
}
must be
the first two characters of the file.
\subsection
{
The Interactive Startup File
}
When you use Python interactively, it is frequently handy to have some
standard commands executed every time the interpreter is started. You
can do this by setting an environment variable named
{
\tt
PYTHONSTARTUP
}
to the name of a file containing your start-up
commands. This is similar to the
{
\tt
/profile
}
feature of the UNIX
shells.
This file is only read in interactive sessions, not when Python reads
commands from a script, and not when
{
\tt
/dev/tty
}
is given as the
explicit source of commands (which otherwise behaves like an
interactive session). It is executed in the same name space where
interactive commands are executed, so that objects that it defines or
imports can be used without qualification in the interactive session.
If you want to read an additional start-up file from the current
directory, you can program this in the global start-up file, e.g.
\verb
\
execfile('.pythonrc')
\
. If you want to use the startup file
in a script, you must write this explicitly in the script, e.g.
\verb
\
import os;
\
\verb
\
execfile(os.environ['PYTHONSTARTUP'])
\
.
\section
{
Interactive Input Editing and History Substitution
}
Some versions of the Python interpreter support editing of the current
...
...
Doc/tut/tut.tex
Dosyayı görüntüle @
9a4e3fc5
...
...
@@ -147,8 +147,8 @@ modules that can save you a lot of time when writing Python programs.
\section
{
Invoking the Interpreter
}
The Python interpreter is usually installed as
{
\tt
/usr/local/python
}
on those machines where it is available; putting
{
\tt
/usr/local
}
in
The Python interpreter is usually installed as
{
\tt
/usr/local/
bin/
python
}
on those machines where it is available; putting
{
\tt
/usr/local
/bin
}
in
your
{
\UNIX
}
shell's search path makes it possible to start it by
typing the command
...
...
@@ -159,7 +159,7 @@ python
to the shell. Since the choice of the directory where the interpreter
lives is an installation option, other places are possible; check with
your local Python guru or system administrator. (E.g.,
{
\tt
/usr/local/
bin/
python
}
is a popular alternative location.)
/usr/local/python
}
is a popular alternative location.)
The interpreter operates somewhat like the
{
\UNIX
}
shell: when called
with standard input connected to a tty device, it reads and executes
...
...
@@ -211,7 +211,7 @@ and a copyright notice before printing the first prompt, e.g.:
\bcode
\begin{verbatim}
python
Python 0.9.
5 (Jan 2
1992).
Python 0.9.
7 (Aug 28
1992).
Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam
>>>
\end{verbatim}
\ecode
...
...
@@ -248,12 +248,12 @@ When a module named {\tt foo} is imported, the interpreter searches
for a file named
{
\tt
foo.py
}
in the list of directories specified by
the environment variable
{
\tt
PYTHONPATH
}
. It has the same syntax as
the
{
\UNIX
}
shell variable
{
\tt
PATH
}
, i.e., a list of colon-separated
directory names. When
{
\tt
PYTHONPATH
}
is not set,
an
i
nstallation-dependent default path is used, usually
{
\t
t
.:/usr/local/lib/python
}
.
directory names. When
{
\tt
PYTHONPATH
}
is not set,
or when the file
i
s not found there, the search continues in an installation-dependen
t
default path, usually
{
\tt
.:/usr/local/lib/python
}
.
Actually, modules are searched in the list of directories given by the
variable
{
\tt
sys.path
}
which is initialized from
{
\tt
PYTHONPATH
}
or
variable
{
\tt
sys.path
}
which is initialized from
{
\tt
PYTHONPATH
}
and
the installation-dependent default. This allows Python programs that
know what they're doing to modify or replace the module search path.
See the section on Standard Modules later.
...
...
@@ -280,13 +280,35 @@ On BSD'ish {\UNIX} systems, Python scripts can be made directly
executable, like shell scripts, by putting the line
\bcode
\begin{verbatim}
#! /usr/local/python
#! /usr/local/
bin/
python
\end{verbatim}
\ecode
%
(assuming that's the name of the interpreter) at the beginning of the
script and giving the file an executable mode. The
{
\tt
\#
!
}
must be
the first two characters of the file.
\subsection
{
The Interactive Startup File
}
When you use Python interactively, it is frequently handy to have some
standard commands executed every time the interpreter is started. You
can do this by setting an environment variable named
{
\tt
PYTHONSTARTUP
}
to the name of a file containing your start-up
commands. This is similar to the
{
\tt
/profile
}
feature of the UNIX
shells.
This file is only read in interactive sessions, not when Python reads
commands from a script, and not when
{
\tt
/dev/tty
}
is given as the
explicit source of commands (which otherwise behaves like an
interactive session). It is executed in the same name space where
interactive commands are executed, so that objects that it defines or
imports can be used without qualification in the interactive session.
If you want to read an additional start-up file from the current
directory, you can program this in the global start-up file, e.g.
\verb
\
execfile('.pythonrc')
\
. If you want to use the startup file
in a script, you must write this explicitly in the script, e.g.
\verb
\
import os;
\
\verb
\
execfile(os.environ['PYTHONSTARTUP'])
\
.
\section
{
Interactive Input Editing and History Substitution
}
Some versions of the Python interpreter support editing of the current
...
...
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