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

Skip to content

Commit 72b83c8

Browse files
committed
SF patch 1094011: Docs for file() vs open().
1 parent bccc9a9 commit 72b83c8

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,12 @@ \section{Built-in Functions \label{built-in-funcs}}
416416
after any I/O has been performed, and there's no reliable way to
417417
determine whether this is the case.}
418418

419-
The \function{file()} constructor is new in Python 2.2. The previous
420-
spelling, \function{open()}, is retained for compatibility, and is an
421-
alias for \function{file()}.
419+
The \function{file()} constructor is new in Python 2.2 and is an
420+
alias for \function{open()}. Both spellings are equivalent. The
421+
intent is for \function{open()} to continue to be preferred for use
422+
as a factory function which returns a new \class{file} object. The
423+
spelling, \class{file} is more suited to type testing (for example,
424+
writing \samp{isinstance(f, file)}).
422425
\end{funcdesc}
423426

424427
\begin{funcdesc}{filter}{function, list}

0 commit comments

Comments
 (0)