Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Python os.openpty() Method with example



Hello dear readers! Welcome back to another section of my Tutorial on Python. In this tutorial guide, we are going to be studying about the Os openpty() method.

The Python os openpty() method opens a pseudo-terminal pair and then it returns a pair of the file descriptors (master, slave) for the pty & tty respectively.

Syntax

The following below is the syntax for Python Os openpty() method -

os.openpty( )

RECOMMENDED POST: Python os.open() Method with example

Parameter Details

  • NA

Return Value

It returns a pair of the file descriptors I.e., master and slave.

Example

The following below is a simple example -

# !/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

Output
When the above code is executed, it will produce the following result -

3
4
3
/dev/pty0

RECOMMENDED POST: Python os.minor() Method with example

Alright guys! This is where we are rounding up for this tutorial post. In my next tutorial, we are going to be discussing about the Python OS pathconf() Method.

Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.


This post first appeared on Web Design Tutorialz, please read the originial post: here

Share the post

Python os.openpty() Method with example

×

Subscribe to Web Design Tutorialz

Get updates delivered right to your inbox!

Thank you for your subscription

×