> >Almost right. The docs for file objects specifically imply that a > >negative arg to readline() or a zero arg to readlines() is the same as > >no args; your defaults are sys.maxint so an explicit -1 or 0 won't do > >the right thing. (This is important for wrapper classes that want to > > Which docs say this? I looked at Doc/lib/libstdtypes.tex to get the > semantics: > > \begin{methoddesc}[file]{readline}{\optional{size}} > ... If the \var{size} argument is present and > non-negative, it is a maximum byte count (including the trailing > newline) and an incomplete line may be returned. ... > \end{methoddesc} I read this that any negative argument has the same effect as an absent argument. I suggested -1 as a typical negative number. The doc could be more explicit though. > \begin{methoddesc}[file]{readlines}{\optional{sizehint}} > ... If the optional \var{sizehint} argument is > present, instead of reading up to \EOF{}, whole lines totalling > approximately \var{sizehint} bytes (possibly after rounding up to an > internal buffer size) are read. > \end{methoddesc} Here you're right -- I got the 0 from the code. It should be documented. > Neither text mentions the special cases for -1 and 0 in each function. > Fixing the patch to get this right is trivial, but I think the docs > need to be updated to mention this. Agreed. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4