Home | History | Annotate | Download | only in pydoc_data

Lines Matching refs:tty

14  'bltin-file-objects': u'\nFile Objects\n************\n\nFile objects are implemented using C\'s "stdio" package and can be\ncreated with the built-in "open()" function.  File objects are also\nreturned by some other built-in functions and methods, such as\n"os.popen()" and "os.fdopen()" and the "makefile()" method of socket\nobjects. Temporary files can be created using the "tempfile" module,\nand high-level file operations such as copying, moving, and deleting\nfiles and directories can be achieved with the "shutil" module.\n\nWhen a file operation fails for an I/O-related reason, the exception\n"IOError" is raised.  This includes situations where the operation is\nnot defined for some reason, like "seek()" on a ttytty(-like) device, else\n   "False".\n\n   Note: If a file-like object is not associated with a real file,\n     this method should *not* be implemented.\n\nfile.next()\n\n   A file object is its own iterator, for example "iter(f)" returns\n   *f* (unless *f* is closed).  When a file is used as an iterator,\n   typically in a "for" loop (for example, "for line in f: print\n   line.strip()"), the "next()" method is called repeatedly.  This\n   method returns the next input line, or raises "StopIteration" when\n   EOF is hit when the file is open for reading (behavior is undefined\n   when the file is open for writing).  In order to make a "for" loop\n   the most efficient way of looping over the lines of a file (a very\n   common operation), the "next()" method uses a hidden read-ahead\n   buffer.  As a consequence of using a read-ahead buffer, combining\n   "next()" with other file methods (like "readline()") does not work\n   right.  However, using "seek()" to reposition the file to an\n   absolute position will flush the read-ahead buffer.\n\n   New in version 2.3.\n\nfile.read([size])\n\n   Read at most *size* bytes from the file (less if the read hits EOF\n   before obtaining *size* bytes).  If the *size* argument is negative\n   or omitted, read all data until EOF is reached.  The bytes are\n   returned as a string object.  An empty string is returned when EOF\n   is encountered immediately.  (For certain files, like ttys, it\n   makes sense to continue reading after an EOF is hit.)  Note that\n   this method may call the underlying C function "fread()" more than\n   once in an effort to acquire as close to *size* bytes as possible.\n   Also note that when in non-blocking mode, less data than was\n   requested may be returned, even if no *size* parameter was given.\n\n   Note: This function is simply a wrapper for the underlying\n     "fread()" C function, and will behave the same in corner cases,\n     such as whether the EOF value is cached.\n\nfile.readline([size])\n\n   Read one entire line from the file.  A trailing newline character\n   is kept in the string (but may be absent when a file ends with an\n   incomplete line). [6] If the *size* argument is present and non-\n   negative, it is a maximum byte count (including the trailing\n   newline) and an incomplete line may be returned. When *size* is not\n   0, an empty string is returned *only* when EOF is encountered\n   immediately.\n\n   Note: Unlike "stdio"\'s "fgets()", the returned string contains\n     null characters ("\'\\0\'") if they occurred in the input.\n\nfile.readlines([sizehint])\n\n   Read until EOF using "readline()" and return a list containing the\n   lines thus read.  If the optional *sizehint* argument is present,\n   instead of reading up to EOF, whole lines totalling approximately\n   *sizehint* bytes (possibly after rounding up to an internal buffer\n   size) are read.  Objects implementing a file-like interface may\n   choose to ignore *sizehint* if it cannot be implemented, or cannot\n   be implemented efficiently.\n\nfile.xreadlines()\n\n   This method returns the same thing as "iter(f)".\n\n   New in version 2.1.\n\n   Deprecated since version 2.3: Use "for line in file" instead.\n\nfile.seek(offset[, whence])\n\n   Set the file\'s current position, like "stdio"\'s "fseek()". The\n   *whence* argument is optional and defaults to  "os.SEEK_SET" or "0"\n   (absolute file positioning); other values are "os.SEEK_CUR" or "1"\n   (seek relative to the current position) and "os.SEEK_END" or "2"\n   (seek relative to the file\'s end).  There is no return value.\n\n   For example, "f.seek(2, os.SEEK_CUR)" advances the position by two\n   and "f.seek(-3, os.SEEK_END)" sets the position to the third to\n   last.\n\n   Note that if the file is opened for appending (mode "\'a\'" or\n   "\'a+\'"), any "seek()" operations will be undone at the next write.\n   If the file is only opened for writing in append mode (mode "\'a\'"),\n   this method is essentially a no-op, but it remains useful for files\n   opened in append mode with reading enabled (mode "\'a+\'").  If the\n   file is opened in text mode (without "\'b\'"), only offsets returned\n   by "tell()" are legal.  Use of other offsets causes undefined\n   behavior.\n\n   Note that not all file objects are seekable.\n\n   Changed in version 2.6: Passing float values as offset has been\n   deprecated.\n\nfile.tell()\n\n   Return the file\'s current position, like "stdio"\'s "ftell()".\n\n   Note: On Windows, "tell()" can return illegal values (after an\n     "fgets()") when reading files with Unix-style line-endings. Use\n     binary mode ("\'rb\'") to circumvent this problem.\n\nfile.truncate([size])\n\n   Truncate the file\'s size.  If the optional *size* argument is\n   present, the file is truncated to (at most) that size.  The size\n   defaults to the current position. The current file position is not\n   changed.  Note that if a specified size exceeds the file\'s current\n   size, the result is platform-dependent:  possibilities include that\n   the file may remain unchanged, increase to the specified size as if\n   zero-filled, or increase to the specified size with undefined new\n   content. Availability:  Windows, many Unix variants.\n\nfile.write(str)\n\n   Write a string to the file.  There is no return value.  Due to\n   buffering, the string may not actually show up in the file until\n   the "flush()" or "close()" method is called.\n\nfile.writelines(sequence)\n\n   Write a sequence of strings to the file.  The sequence can be any\n   iterable object producing strings, typically a list of strings.\n   There is no return value. (The name is intended to match\n   "readlines()"; "writelines()" does not add line separators.)\n\nFiles support the iterator protocol.  Each iteration returns the same\nresult as "readline()", and iteration ends when the "readline()"\nmethod returns an empty string.\n\nFile objects also offer a number of other interesting attributes.\nThese are not required for file-like objects, but should be\nimplemented if they make sense for the particular object.\n\nfile.closed\n\n   bool indicating the current state of the file object.  This is a\n   read-only attribute; the "close()" method changes the value. It may\n   not be available on all file-like objects.\n\nfile.encoding\n\n   The encoding that this file uses. When Unicode strings are written\n   to a file, they will be converted to byte strings using this\n   encoding. In addition, when the file is connected to a terminal,\n   the attribute gives the encoding that the terminal is likely to use\n   (that  information might be incorrect if the user has misconfigured\n   the  terminal). The attribute is read-only and may not be present\n   on all file-like objects. It may also be "None", in which case the\n   file uses the system default encoding for converting Unicode\n   strings.\n\n   New in version 2.3.\n\nfile.errors\n\n   The Unicode error handler used along with the encoding.\n\n   New in version 2.6.\n\nfile.mode\n\n   The I/O mode for the file.  If the file was created using the\n   "open()" built-in function, this will be the value of the *mode*\n   parameter.  This is a read-only attribute and may not be present on\n   all file-like objects.\n\nfile.name\n\n   If the file object was created using "open()", the name of the\n   file. Otherwise, some string that indicates the source of the file\n   object, of the form "<...>".  This is a read-only attribute and may\n   not be present on all file-like objects.\n\nfile.newlines\n\n   If Python was built with *universal newlines* enabled (the default)\n   this read-only attribute exists, and for files opened in universal\n   newline read mode it keeps track of the types of newlines\n   encountered while reading the file. The values it can take are\n   "\'\\r\'", "\'\\n\'", "\'\\r\\n\'", "None" (unknown, no newlines read yet) or\n   a tuple containing all the newline types seen, to indicate that\n   multiple newline conventions were encountered. For files not opened\n   in universal newlines read mode the value of this attribute will be\n   "None".\n\nfile.softspace\n\n   Boolean that indicates whether a space character needs to be\n   printed before another value when using the "print" statement.\n   Classes that are trying to simulate a file object should also have\n   a writable "softspace" attribute, which should be initialized to\n   zero.  This will be automatic for most classes implemented in\n   Python (care may be needed for objects that override attribute\n   access); types implemented in C will have to provide a writable\n   "softspace" attribute.\n\n   Note: This attribute is not used to control the "print"\n     statement, but to allow the implementation of "print" to keep\n     track of its internal state.\n',