Python method openpty() opens a pseudo-terminal pair and returns a pair of file descriptors(master, slave) for the pty & the tty respectively.
Following is the syntax for openpty() method:
os.openpty()
This method returns a pair of file descriptors i.e., master and slave.
Example
The following example shows the usage of openpty() method.
# !/usr/bin/python import os # master for pty, slave for tty m,s = os.openpty() print m print s # showing terminal name s = os.ttyname(s) print m print s
When we run above program, it produces following result:
3 4 3 /dev/pty0
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.