28.10.2021 Views

Python Tutorial ( PDFDrive )

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Syntax

Following is the syntax for tcsetpgrp() method:

os.tcsetpgrp(fd, pg)

Parameters

• fd -- This is the file descriptor.

• pg -- This set the process group to pg.

Return Value

This method does not return any value.

Example

The following example shows the usage of tcsetpgrp() method.

# !/usr/bin/python

import os, sys

# Showing current directory

print "Current working dir :%s" %os.getcwd()

# Changing dir to /dev/tty

fd = os.open("/dev/tty",os.O_RDONLY)

f = os.tcgetpgrp(fd)

# Showing the process group

print "the process group associated is: "

print f

# Setting the process group

os.tcsetpgrp(fd,2672)

print "done"

os.close(fd)

print "Closed the file successfully!!"

Let us compile and run the above program, this will produce the following result:

Current working dir is :/tmp

the process group associated is:

2672

done

Closed the file successfully!!

os.tempnam([dir[, prefix]])

Description

The method tempnam() returns a unique path name that is reasonable for creating a temporary file.

Syntax

Following is the syntax for tempnam() method:

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!