Package wtf :: Module _wtf_cstream :: Class GenericStream
[hide private]
[frames] | no frames]

Class GenericStream

object --+
         |
        GenericStream

GenericStream(stream[, buffering])

Represents a buffered stream

Instance Methods [hide private]
 
__del__(...)
 
__iter__(x)
iter(x)
a new object with type S, a subtype of T
__new__(T, S, ...)
 
close(...)
s.close()
 
fileno(...)
s.fileno()
 
flush(...)
s.flush()
bool
isatty(...)
s.isatty()
the next value, or raise StopIteration
next(x)
str
read(...)
s.read([size]) -> str
str
read_exact(...)
s.read_exact([size]) -> str
str
readline(...)
s.readline([size]) -> line
list
readlines(...)
s.readlines([size]) -> [line, ...]
 
write(...)
s.write(data)
 
writelines(...)
s.writelines(lines)
 
xreadlines(...)
s.xreadlines()

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  closed
  name
  softspace

Inherited from object: __class__

Method Details [hide private]

__new__(T, S, ...)

 


Returns: a new object with type S, a subtype of T
Overrides: object.__new__

close(...)

 

s.close()

Close the stream

The call is passed to the underlying octet stream.

fileno(...)

 

s.fileno()

Determine underlying fileno

flush(...)

 

s.flush()

Flush the write buffer

isatty(...)

 

s.isatty()

Does the stream refer to a tty?

Returns: bool
Does the stream refer to a tty?

read(...)

 

s.read([size]) -> str

Reads a specified amount of bytes (at max) from the stream

Parameters

  • size: The maximum number of bytes to read (< 0 means to slurp the whole stream; == 0 means to return the current buffer or the next buffer it the current buffer is empty)

Types

  • size: int
Returns: str
The read bytes; if empty you've hit EOF
Raises:
  • ValueError - The stream is closed

read_exact(...)

 

s.read_exact([size]) -> str

Read exactly size bytes from stream, except on EOF

Parameters

  • size: The maximum number of bytes to read (< 0 means to slurp the whole stream; == 0 means to return the current buffer or the next buffer it the current buffer is empty)

Types

  • size: int
Returns: str
The read bytes; if empty you've hit EOF
Raises:
  • ValueError - The stream is closed

readline(...)

 

s.readline([size]) -> line

Read a line from the stream

Parameters

  • size: The maximum number of bytes to read (<= 0 means to read until the next newline or EOF, which is the default behaviour)

Types

  • size: int
Returns: str
The read bytes including the newline; if empty you've hit EOF

readlines(...)

 

s.readlines([size]) -> [line, ...]

Read all lines from the stream

Parameters

  • size: The maximum number of bytes to read per line (<= 0 means to read until the next newline or EOF, which is the default behaviour)

Types

  • size: int
Returns: list
The list of lines

write(...)

 

s.write(data)

Write data into the stream

Parameters

  • data: The data to write

Types

  • data: str

writelines(...)

 

s.writelines(lines)

Write lines to the stream

Parameters

  • lines: The list of lines to write

Types

  • lines: iterable

xreadlines(...)

 

s.xreadlines()

Iterator of the lines

Deprecated: Use the iterator API instead