YouTip LogoYouTip

Os Closerange

# Python2.x Python os.closerange() Method [![Image 3: Python File Methods](#) Python OS File/Directory Methods](#) * * * ### Overview The os.closerange() method is used to close all file descriptors fd, from fd_low (inclusive) to fd_high (exclusive), ignoring errors. ### Syntax The syntax format of the **closerange()** method is as follows: os.closerange(fd_low, fd_high); ### Parameters * **fd_low** -- Minimum file descriptor * **fd_high** -- Maximum file descriptor This method is similar to: for fd in xrange(fd_low, fd_high): try: os.close(fd) except OSError: pass ### Return Value This method has no return value. ### Example The following example demonstrates the use of the closerange() method: #!/usr/bin/python# -*- coding: UTF-8 -*-import os, sys # Open file fd
← Linux Comm UnsetOs Closerange β†’