pg.io.File

Accessible via pg.io.File.

class File[source]

Bases: object

Interface for a file.

Methods:

close()

Closes the file.

read([size])

Reads the content of the file.

readline()

Reads the next line.

seek(offset[, whence])

Changes the current position of the file.

tell()

Returns the current position of the file.

write(content)

Writes the content of the file.

abstract close()[source]

Closes the file.

Return type:

None

abstract read(size=None)[source]

Reads the content of the file.

Return type:

Union[str, bytes]

abstract readline()[source]

Reads the next line.

Return type:

Union[str, bytes]

abstract seek(offset, whence=0)[source]

Changes the current position of the file.

Return type:

int

Parameters:
  • offset – Offset from the position to a reference point.

  • whence – The reference point, with 0 meaning the beginning of the file, 1 meaning the current position, or 2 meaning the end of the file.

Returns:

The position from the beginning of the file.

abstract tell()[source]

Returns the current position of the file.

Return type:

int

abstract write(content)[source]

Writes the content of the file.

Return type:

None