Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python os.openpty() method

Python os.openpty() method

Python File methods Python OS file/directory methods


Overview

The os.openpty() method opens a new pseudo-terminal pair. It returns the file descriptors of the pty and tty.

Syntax

The **openpty()** method syntax is as follows:



os.openpty()

Parameters

Return Value

Returns a pair of file descriptors, master and slave.

Example

The following example demonstrates the use of the openpty() method:



#!/usr/bin/python

# -*- coding: UTF-8 -*-



import os



# main pty, from tty

m,s = os.openpty()



print m

print s



# Display terminal name

s = os.ttyname(s)

print m

print s

The output of the above program is:



3

4

3

/dev/pty0

Python File methods Python OS file/directory methods