YouTip LogoYouTip

Python3 Os Openpty

# Python3.x Python3 os.openpty() Method [![Image 3: Python3 OS File/Directory Methods](#) 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 The syntax for the `openpty()` method is as follows: os.openpty() ### Parameters * None ### Return Value Returns a pair of file descriptors, master and slave. ### Example The following example demonstrates the usage of the `openpty()` method: #!/usr/bin/python3import os # master pty, slave 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: 343/dev/pty0 [![Image 4: Python3 OS File/Directory Methods](#) Python3 OS File/Directory Methods](#)
← Python3 Os OpenptyPython3 Os Mknod β†’