Easy Tutorial
❮ Python Att Dictionary Fromkeys Python Remove Duplicate From List ❯

Python3 os.openpty() Method

Python3 OS File/Directory Methods


Overview

The os.openpty() method is used to open a new pseudo-terminal pair. It returns the file descriptors for the pty and tty.

Syntax

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/python3

import os

# Master pty, slave tty
m, s = os.openpty()

print(m)
print(s)

# Display terminal name
s = os.ttyname(s)
print(m)
print(s)

Executing the above program outputs:

3
4
3
/dev/pty0

Python3 OS File/Directory Methods

❮ Python Att Dictionary Fromkeys Python Remove Duplicate From List ❯