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
9ae080ee
Kaydet (Commit)
9ae080ee
authored
May 04, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove method signatures from the docstrings of io.py
üst
8d66dcd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
50 deletions
+38
-50
io.py
Lib/io.py
+38
-50
No files found.
Lib/io.py
Dosyayı görüntüle @
9ae080ee
...
@@ -81,9 +81,8 @@ class BlockingIOError(IOError):
...
@@ -81,9 +81,8 @@ class BlockingIOError(IOError):
def
open
(
file
,
mode
=
"r"
,
buffering
=
None
,
encoding
=
None
,
errors
=
None
,
def
open
(
file
,
mode
=
"r"
,
buffering
=
None
,
encoding
=
None
,
errors
=
None
,
newline
=
None
,
closefd
=
True
):
newline
=
None
,
closefd
=
True
):
r"""
r"""Open file and return a stream. If the file cannot be opened, an IOError is
Open file and return a stream. If the file cannot be opened, an
raised.
IOError is raised.
file is either a string giving the name (and the path if the file
file is either a string giving the name (and the path if the file
isn't in the current working directory) of the file to be opened or an
isn't in the current working directory) of the file to be opened or an
...
@@ -290,8 +289,7 @@ class UnsupportedOperation(ValueError, IOError):
...
@@ -290,8 +289,7 @@ class UnsupportedOperation(ValueError, IOError):
class
IOBase
(
object
):
class
IOBase
(
object
):
"""
"""The abstract base class for all I/O classes, acting on streams of
The abstract base class for all I/O classes, acting on streams of
bytes. There is no public constructor.
bytes. There is no public constructor.
This class provides dummy implementations for many methods that
This class provides dummy implementations for many methods that
...
@@ -333,7 +331,7 @@ class IOBase(object):
...
@@ -333,7 +331,7 @@ class IOBase(object):
### Positioning ###
### Positioning ###
def
seek
(
self
,
pos
,
whence
=
0
):
def
seek
(
self
,
pos
,
whence
=
0
):
"""
seek(pos: int, whence: int = 0) -> int.
Change stream position.
"""Change stream position.
Change the stream position to byte offset offset. offset is
Change the stream position to byte offset offset. offset is
interpreted relative to the position indicated by whence. Values
interpreted relative to the position indicated by whence. Values
...
@@ -348,21 +346,21 @@ class IOBase(object):
...
@@ -348,21 +346,21 @@ class IOBase(object):
self
.
_unsupported
(
"seek"
)
self
.
_unsupported
(
"seek"
)
def
tell
(
self
):
def
tell
(
self
):
"""
tell() -> int.
Return current stream position."""
"""Return current stream position."""
return
self
.
seek
(
0
,
1
)
return
self
.
seek
(
0
,
1
)
def
truncate
(
self
,
pos
=
None
):
def
truncate
(
self
,
pos
=
None
):
"""
truncate(size: int = None) -> int.
Truncate file to size bytes.
"""Truncate file to size bytes.
Size defaults to the current IO position as reported by tell().
Size defaults to the current IO position as reported by tell().
Return
Returns
the new size.
the new size.
"""
"""
self
.
_unsupported
(
"truncate"
)
self
.
_unsupported
(
"truncate"
)
### Flush and close ###
### Flush and close ###
def
flush
(
self
):
def
flush
(
self
):
"""
flush() -> None. Flushes
write buffers, if applicable.
"""
Flush
write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
This is not implemented for read-only and non-blocking streams.
"""
"""
...
@@ -371,7 +369,7 @@ class IOBase(object):
...
@@ -371,7 +369,7 @@ class IOBase(object):
__closed
=
False
__closed
=
False
def
close
(
self
):
def
close
(
self
):
"""
close() -> None. Flushes and closes
the IO object.
"""
Flush and close
the IO object.
This method has no effect if the file is already closed.
This method has no effect if the file is already closed.
"""
"""
...
@@ -397,7 +395,7 @@ class IOBase(object):
...
@@ -397,7 +395,7 @@ class IOBase(object):
### Inquiries ###
### Inquiries ###
def
seekable
(
self
):
def
seekable
(
self
):
"""
seekable() -> bool.
Return whether object supports random access.
"""Return whether object supports random access.
If False, seek(), tell() and truncate() will raise IOError.
If False, seek(), tell() and truncate() will raise IOError.
This method may need to do a test seek().
This method may need to do a test seek().
...
@@ -413,7 +411,7 @@ class IOBase(object):
...
@@ -413,7 +411,7 @@ class IOBase(object):
def
readable
(
self
):
def
readable
(
self
):
"""
readable() -> bool.
Return whether object was opened for reading.
"""Return whether object was opened for reading.
If False, read() will raise IOError.
If False, read() will raise IOError.
"""
"""
...
@@ -427,7 +425,7 @@ class IOBase(object):
...
@@ -427,7 +425,7 @@ class IOBase(object):
if
msg
is
None
else
msg
)
if
msg
is
None
else
msg
)
def
writable
(
self
):
def
writable
(
self
):
"""
writable() -> bool.
Return whether object was opened for writing.
"""Return whether object was opened for writing.
If False, write() and truncate() will raise IOError.
If False, write() and truncate() will raise IOError.
"""
"""
...
@@ -471,16 +469,16 @@ class IOBase(object):
...
@@ -471,16 +469,16 @@ class IOBase(object):
# XXX Should these be present even if unimplemented?
# XXX Should these be present even if unimplemented?
def
fileno
(
self
):
def
fileno
(
self
):
"""
fileno() -> int.
Returns underlying file descriptor if one exists.
"""Returns underlying file descriptor if one exists.
Raises IOError
if the IO object does not use a file descriptor.
An IOError is raised
if the IO object does not use a file descriptor.
"""
"""
self
.
_unsupported
(
"fileno"
)
self
.
_unsupported
(
"fileno"
)
def
isatty
(
self
):
def
isatty
(
self
):
"""
isatty() -> int. Returns
whether this is an 'interactive' stream.
"""
Return
whether this is an 'interactive' stream.
Return
s False if we don't know
.
Return
False if it can't be determined
.
"""
"""
self
.
_checkClosed
()
self
.
_checkClosed
()
return
False
return
False
...
@@ -488,8 +486,7 @@ class IOBase(object):
...
@@ -488,8 +486,7 @@ class IOBase(object):
### Readline[s] and writelines ###
### Readline[s] and writelines ###
def
readline
(
self
,
limit
=
-
1
):
def
readline
(
self
,
limit
=
-
1
):
r"""readline(limit: int = -1) -> bytes Read and return a line from the
r"""Read and return a line from the stream.
stream.
If limit is specified, at most limit bytes will be read.
If limit is specified, at most limit bytes will be read.
...
@@ -532,7 +529,7 @@ class IOBase(object):
...
@@ -532,7 +529,7 @@ class IOBase(object):
return
line
return
line
def
readlines
(
self
,
hint
=
None
):
def
readlines
(
self
,
hint
=
None
):
"""
readlines(hint=None) -> list
Return a list of lines from the stream.
"""Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more
hint can be specified to control the number of lines read: no more
lines will be read if the total size (in bytes/characters) of all
lines will be read if the total size (in bytes/characters) of all
...
@@ -570,7 +567,7 @@ class RawIOBase(IOBase):
...
@@ -570,7 +567,7 @@ class RawIOBase(IOBase):
# a subclass doesn't implement either.)
# a subclass doesn't implement either.)
def
read
(
self
,
n
=
-
1
):
def
read
(
self
,
n
=
-
1
):
"""
read(n: int) -> bytes.
Read and return up to n bytes.
"""Read and return up to n bytes.
Returns an empty bytes array on EOF, or None if the object is
Returns an empty bytes array on EOF, or None if the object is
set not to block and has no data to read.
set not to block and has no data to read.
...
@@ -585,7 +582,7 @@ class RawIOBase(IOBase):
...
@@ -585,7 +582,7 @@ class RawIOBase(IOBase):
return
bytes
(
b
)
return
bytes
(
b
)
def
readall
(
self
):
def
readall
(
self
):
"""
readall() -> bytes.
Read until EOF, using multiple read() call."""
"""Read until EOF, using multiple read() call."""
res
=
bytearray
()
res
=
bytearray
()
while
True
:
while
True
:
data
=
self
.
read
(
DEFAULT_BUFFER_SIZE
)
data
=
self
.
read
(
DEFAULT_BUFFER_SIZE
)
...
@@ -595,7 +592,7 @@ class RawIOBase(IOBase):
...
@@ -595,7 +592,7 @@ class RawIOBase(IOBase):
return
bytes
(
res
)
return
bytes
(
res
)
def
readinto
(
self
,
b
):
def
readinto
(
self
,
b
):
"""
readinto(b: bytes) -> int.
Read up to len(b) bytes into b.
"""Read up to len(b) bytes into b.
Returns number of bytes read (0 for EOF), or None if the object
Returns number of bytes read (0 for EOF), or None if the object
is set not to block as has no data to read.
is set not to block as has no data to read.
...
@@ -603,7 +600,7 @@ class RawIOBase(IOBase):
...
@@ -603,7 +600,7 @@ class RawIOBase(IOBase):
self
.
_unsupported
(
"readinto"
)
self
.
_unsupported
(
"readinto"
)
def
write
(
self
,
b
):
def
write
(
self
,
b
):
"""
write(b: bytes) -> int.
Write the given buffer to the IO stream.
"""Write the given buffer to the IO stream.
Returns the number of bytes written, which may be less than len(b).
Returns the number of bytes written, which may be less than len(b).
"""
"""
...
@@ -650,7 +647,7 @@ class BufferedIOBase(IOBase):
...
@@ -650,7 +647,7 @@ class BufferedIOBase(IOBase):
"""
"""
def
read
(
self
,
n
=
None
):
def
read
(
self
,
n
=
None
):
"""
read(n: int = None) -> bytes.
Read and return up to n bytes.
"""Read and return up to n bytes.
If the argument is omitted, None, or negative, reads and
If the argument is omitted, None, or negative, reads and
returns all data until EOF.
returns all data until EOF.
...
@@ -670,7 +667,7 @@ class BufferedIOBase(IOBase):
...
@@ -670,7 +667,7 @@ class BufferedIOBase(IOBase):
self
.
_unsupported
(
"read"
)
self
.
_unsupported
(
"read"
)
def
readinto
(
self
,
b
):
def
readinto
(
self
,
b
):
"""
readinto(b: bytearray) -> int.
Read up to len(b) bytes into b.
"""Read up to len(b) bytes into b.
Like read(), this may issue multiple reads to the underlying raw
Like read(), this may issue multiple reads to the underlying raw
stream, unless the latter is 'interactive'.
stream, unless the latter is 'interactive'.
...
@@ -693,9 +690,9 @@ class BufferedIOBase(IOBase):
...
@@ -693,9 +690,9 @@ class BufferedIOBase(IOBase):
return
n
return
n
def
write
(
self
,
b
):
def
write
(
self
,
b
):
"""
write(b: bytes) -> int.
Write the given buffer to the IO stream.
"""Write the given buffer to the IO stream.
Return
s
the number of bytes written, which is never less than
Return the number of bytes written, which is never less than
len(b).
len(b).
Raises BlockingIOError if the buffer is full and the
Raises BlockingIOError if the buffer is full and the
...
@@ -785,7 +782,7 @@ class BytesIO(BufferedIOBase):
...
@@ -785,7 +782,7 @@ class BytesIO(BufferedIOBase):
self
.
_pos
=
0
self
.
_pos
=
0
def
getvalue
(
self
):
def
getvalue
(
self
):
"""
getvalue() -> bytes
Return the bytes value (contents) of the buffer
"""Return the bytes value (contents) of the buffer
"""
"""
return
bytes
(
self
.
_buffer
)
return
bytes
(
self
.
_buffer
)
...
@@ -800,7 +797,7 @@ class BytesIO(BufferedIOBase):
...
@@ -800,7 +797,7 @@ class BytesIO(BufferedIOBase):
return
bytes
(
b
)
return
bytes
(
b
)
def
read1
(
self
,
n
):
def
read1
(
self
,
n
):
"""
In BytesIO,
this is the same as read.
"""this is the same as read.
"""
"""
return
self
.
read
(
n
)
return
self
.
read
(
n
)
...
@@ -939,9 +936,7 @@ class BufferedReader(_BufferedIOMixin):
...
@@ -939,9 +936,7 @@ class BufferedReader(_BufferedIOMixin):
class
BufferedWriter
(
_BufferedIOMixin
):
class
BufferedWriter
(
_BufferedIOMixin
):
"""BufferedWriter(raw[, buffer_size[, max_buffer_size]])
"""A buffer for a writeable sequential RawIO object.
A buffer for a writeable sequential RawIO object.
The constructor creates a BufferedWriter for the given writeable raw
The constructor creates a BufferedWriter for the given writeable raw
stream. If the buffer_size is not given, it defaults to
stream. If the buffer_size is not given, it defaults to
...
@@ -1079,9 +1074,7 @@ class BufferedRWPair(BufferedIOBase):
...
@@ -1079,9 +1074,7 @@ class BufferedRWPair(BufferedIOBase):
class
BufferedRandom
(
BufferedWriter
,
BufferedReader
):
class
BufferedRandom
(
BufferedWriter
,
BufferedReader
):
"""BufferedRandom(raw[, buffer_size[, max_buffer_size]])
"""A buffered interface to random access streams.
A buffered interface to random access streams.
The constructor creates a reader and writer for a seekable stream,
The constructor creates a reader and writer for a seekable stream,
raw, given in the first argument. If the buffer_size is omitted it
raw, given in the first argument. If the buffer_size is omitted it
...
@@ -1144,7 +1137,7 @@ class TextIOBase(IOBase):
...
@@ -1144,7 +1137,7 @@ class TextIOBase(IOBase):
"""
"""
def
read
(
self
,
n
=
-
1
):
def
read
(
self
,
n
=
-
1
):
"""
read(n: int = -1) -> unicode.
Read at most n characters from stream.
"""Read at most n characters from stream.
Read from underlying buffer until we have n characters or we hit EOF.
Read from underlying buffer until we have n characters or we hit EOF.
If n is negative or omitted, read until EOF.
If n is negative or omitted, read until EOF.
...
@@ -1152,11 +1145,11 @@ class TextIOBase(IOBase):
...
@@ -1152,11 +1145,11 @@ class TextIOBase(IOBase):
self
.
_unsupported
(
"read"
)
self
.
_unsupported
(
"read"
)
def
write
(
self
,
s
):
def
write
(
self
,
s
):
"""
write(s: unicode) -> int.
Write string s to stream."""
"""Write string s to stream."""
self
.
_unsupported
(
"write"
)
self
.
_unsupported
(
"write"
)
def
truncate
(
self
,
pos
=
None
):
def
truncate
(
self
,
pos
=
None
):
"""
truncate(pos: int = None) -> int.
Truncate size to pos."""
"""Truncate size to pos."""
self
.
flush
()
self
.
flush
()
if
pos
is
None
:
if
pos
is
None
:
pos
=
self
.
tell
()
pos
=
self
.
tell
()
...
@@ -1164,7 +1157,7 @@ class TextIOBase(IOBase):
...
@@ -1164,7 +1157,7 @@ class TextIOBase(IOBase):
return
self
.
buffer
.
truncate
()
return
self
.
buffer
.
truncate
()
def
readline
(
self
):
def
readline
(
self
):
"""
readline() -> unicode.
Read until newline or EOF.
"""Read until newline or EOF.
Returns an empty string if EOF is hit immediately.
Returns an empty string if EOF is hit immediately.
"""
"""
...
@@ -1177,8 +1170,7 @@ class TextIOBase(IOBase):
...
@@ -1177,8 +1170,7 @@ class TextIOBase(IOBase):
@property
@property
def
newlines
(
self
):
def
newlines
(
self
):
"""newlines -> None | unicode | tuple of unicode. Line endings translated
"""Line endings translated so far.
so far.
Only line endings translated during reading are considered.
Only line endings translated during reading are considered.
...
@@ -1268,9 +1260,7 @@ class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
...
@@ -1268,9 +1260,7 @@ class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
class
TextIOWrapper
(
TextIOBase
):
class
TextIOWrapper
(
TextIOBase
):
r"""TextIOWrapper(buffer[, encoding[, errors[, newline[, line_buffering]]]])
r"""Character and line based layer over a BufferedIOBase object, buffer.
Character and line based layer over a BufferedIOBase object, buffer.
encoding gives the name of the encoding that the stream will be
encoding gives the name of the encoding that the stream will be
decoded or encoded with. It defaults to locale.getpreferredencoding.
decoded or encoded with. It defaults to locale.getpreferredencoding.
...
@@ -1727,9 +1717,7 @@ class TextIOWrapper(TextIOBase):
...
@@ -1727,9 +1717,7 @@ class TextIOWrapper(TextIOBase):
class
StringIO
(
TextIOWrapper
):
class
StringIO
(
TextIOWrapper
):
"""StringIO([initial_value[, encoding, [errors, [newline]]]])
"""An in-memory stream for text. The initial_value argument sets the
An in-memory stream for text. The initial_value argument sets the
value of object. The other arguments are like those of TextIOWrapper's
value of object. The other arguments are like those of TextIOWrapper's
constructor.
constructor.
"""
"""
...
...
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