Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c43c59

Browse files
committed
More emphasis on os.environ's calling of putenv; and added hint about
flags for open().
1 parent 7d6b7d3 commit 9c43c59

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

Doc/lib/libposix.tex

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ \section{Built-in Module \sectcode{posix}}
1313
\code{posix} module is not available, but a subset is always available
1414
through the \code{os} interface. Once \code{os} is imported, there is
1515
\emph{no} performance penalty in using it instead of
16-
\code{posix}.
16+
\code{posix}. In addition, \code{os} provides some additional
17+
functionality, such as automatically calling \code{putenv()}
18+
when an entry is \code{os.environ} is changed.
1719
\stmodindex{os}
1820

1921
The descriptions below are very terse; refer to the
@@ -35,13 +37,17 @@ \section{Built-in Module \sectcode{posix}}
3537
is the pathname of your home directory, equivalent to
3638
\code{getenv("HOME")}
3739
in C.
40+
3841
Modifying this dictionary does not affect the string environment
3942
passed on by \code{execv()}, \code{popen()} or \code{system()}; if you
4043
need to change the environment, pass \code{environ} to \code{execve()}
4144
or add variable assignments and export statements to the command
42-
string for \code{system()} or \code{popen()}.%
43-
\footnote{The problem with automatically passing on \code{environ} is
44-
that there is no portable way of changing the environment.}
45+
string for \code{system()} or \code{popen()}.
46+
47+
\emph{However:} If you are using this module via the \code{os} module
48+
(as you should -- see the introduction above), \code{environ} is a
49+
a mapping object that behaves almost like a dictionary but invokes
50+
\code{putenv()} automatically called whenever an item is changed.
4551
\end{datadesc}
4652

4753
\renewcommand{\indexsubitem}{(exception in module posix)}
@@ -238,6 +244,10 @@ \section{Built-in Module \sectcode{posix}}
238244
first masked out. Return the file descriptor for the newly opened
239245
file.
240246

247+
For a description of the flag and mode values, see the \UNIX{} or C
248+
run-time documentation; flag constants (like \code{O_RDONLY} and
249+
\code{O_WRONLY}) are defined in this module too (see below).
250+
241251
Note: this function is intended for low-level I/O. For normal usage,
242252
use the built-in function \code{open}, which returns a ``file object''
243253
with \code{read()} and \code{write()} methods (and many more).

Doc/libposix.tex

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ \section{Built-in Module \sectcode{posix}}
1313
\code{posix} module is not available, but a subset is always available
1414
through the \code{os} interface. Once \code{os} is imported, there is
1515
\emph{no} performance penalty in using it instead of
16-
\code{posix}.
16+
\code{posix}. In addition, \code{os} provides some additional
17+
functionality, such as automatically calling \code{putenv()}
18+
when an entry is \code{os.environ} is changed.
1719
\stmodindex{os}
1820

1921
The descriptions below are very terse; refer to the
@@ -35,13 +37,17 @@ \section{Built-in Module \sectcode{posix}}
3537
is the pathname of your home directory, equivalent to
3638
\code{getenv("HOME")}
3739
in C.
40+
3841
Modifying this dictionary does not affect the string environment
3942
passed on by \code{execv()}, \code{popen()} or \code{system()}; if you
4043
need to change the environment, pass \code{environ} to \code{execve()}
4144
or add variable assignments and export statements to the command
42-
string for \code{system()} or \code{popen()}.%
43-
\footnote{The problem with automatically passing on \code{environ} is
44-
that there is no portable way of changing the environment.}
45+
string for \code{system()} or \code{popen()}.
46+
47+
\emph{However:} If you are using this module via the \code{os} module
48+
(as you should -- see the introduction above), \code{environ} is a
49+
a mapping object that behaves almost like a dictionary but invokes
50+
\code{putenv()} automatically called whenever an item is changed.
4551
\end{datadesc}
4652

4753
\renewcommand{\indexsubitem}{(exception in module posix)}
@@ -238,6 +244,10 @@ \section{Built-in Module \sectcode{posix}}
238244
first masked out. Return the file descriptor for the newly opened
239245
file.
240246

247+
For a description of the flag and mode values, see the \UNIX{} or C
248+
run-time documentation; flag constants (like \code{O_RDONLY} and
249+
\code{O_WRONLY}) are defined in this module too (see below).
250+
241251
Note: this function is intended for low-level I/O. For normal usage,
242252
use the built-in function \code{open}, which returns a ``file object''
243253
with \code{read()} and \code{write()} methods (and many more).

0 commit comments

Comments
 (0)