InputStream Class
File-like object representing an input blob.
- Inheritance
-
InputStreamInputStream
Constructor
InputStream()
Methods
close |
Flush and close the IO object. This method has no effect if the file is already closed. |
detach |
Disconnect this buffer from its underlying raw stream and return it. After the raw stream has been detached, the buffer is in an unusable state. |
fileno |
Returns underlying file descriptor if one exists. OSError is raised if the IO object does not use a file descriptor. |
flush |
Flush write buffers, if applicable. This is not implemented for read-only and non-blocking streams. |
isatty |
Return whether this is an 'interactive' stream. Return False if it can't be determined. |
read |
Return and read up to size bytes. |
read1 |
Read and return up to n bytes, with at most one read() call to the underlying raw stream. A short result does not imply that EOF is imminent. Returns an empty bytes object on EOF. |
readable |
Return whether object was opened for reading. If False, read() will raise OSError. |
readinto | |
readinto1 | |
readline |
Read and return a line from the stream. If size is specified, at most size bytes will be read. The line terminator is always b'n' for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized. |
readlines |
Return a list of lines from the stream. 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 so far exceeds hint. |
seek |
Change the stream position to the given byte offset. offset The stream position, relative to 'whence'. whence The relative position to seek from. The offset is interpreted relative to the position indicated by whence. Values for whence are:
Return the new absolute position. |
seekable |
Return whether object supports random access. If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek(). |
tell |
Return current stream position. |
truncate |
Truncate file to size bytes. File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size. |
writable |
Return whether object was opened for writing. If False, write() will raise OSError. |
write |
Write the given buffer to the IO stream. Returns the number of bytes written, which is always the length of b in bytes. Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment. |
writelines |
Write a list of lines to stream. Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end. |
close
Flush and close the IO object.
This method has no effect if the file is already closed.
close()
detach
Disconnect this buffer from its underlying raw stream and return it.
After the raw stream has been detached, the buffer is in an unusable state.
detach()
fileno
Returns underlying file descriptor if one exists.
OSError is raised if the IO object does not use a file descriptor.
fileno()
flush
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
flush()
isatty
Return whether this is an 'interactive' stream.
Return False if it can't be determined.
isatty()
read
Return and read up to size bytes.
abstract read(size=-1) -> bytes
Parameters
Name | Description |
---|---|
size
|
The number of bytes to read. If the argument is omitted,
Default value: -1
|
Returns
Type | Description |
---|---|
Bytes read from the input stream. |
read1
Read and return up to n bytes, with at most one read() call to the underlying raw stream. A short result does not imply that EOF is imminent.
Returns an empty bytes object on EOF.
read1()
readable
Return whether object was opened for reading.
If False, read() will raise OSError.
readable()
readinto
readinto(buffer, /)
Positional-Only Parameters
Name | Description |
---|---|
buffer
Required
|
|
readinto1
readinto1(buffer, /)
Positional-Only Parameters
Name | Description |
---|---|
buffer
Required
|
|
readline
Read and return a line from the stream.
If size is specified, at most size bytes will be read.
The line terminator is always b'n' for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.
readline(size=-1, /)
Positional-Only Parameters
Name | Description |
---|---|
size
|
Default value: -1
|
readlines
Return a list of lines from the stream.
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 so far exceeds hint.
readlines(hint=-1, /)
Positional-Only Parameters
Name | Description |
---|---|
hint
|
Default value: -1
|
seek
Change the stream position to the given byte offset.
offset The stream position, relative to 'whence'.
whence The relative position to seek from.
The offset is interpreted relative to the position indicated by whence. Values for whence are:
os.SEEK_SET or 0 – start of stream (the default); offset should be zero or positive
os.SEEK_CUR or 1 – current stream position; offset may be negative
os.SEEK_END or 2 – end of stream; offset is usually negative
Return the new absolute position.
seek(offset, whence=0, /)
Positional-Only Parameters
Name | Description |
---|---|
offset
Required
|
|
whence
|
Default value: 0
|
seekable
Return whether object supports random access.
If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().
seekable()
tell
Return current stream position.
tell()
truncate
Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.
truncate()
writable
Return whether object was opened for writing.
If False, write() will raise OSError.
writable()
write
Write the given buffer to the IO stream.
Returns the number of bytes written, which is always the length of b in bytes.
Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment.
write()
writelines
Write a list of lines to stream.
Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.
writelines(lines, /)
Positional-Only Parameters
Name | Description |
---|---|
lines
Required
|
|
Attributes
closed
length
name
uri
Azure SDK for Python