i

Python Programming

The file-Object-Attributes

When a file is opened and you have one file object, you can get various-information related to file.

Below is the list of attributes.

Sr.No.    Attribute / Description

1    file.closed (attribute/description)

It returns true if file is closed, false otherwise.

2    file.mode (attribute/description)

It returns access mode with which file was opened.

3    file.name (attribute/description)

It returns the name of the file.

4    file.softspace (attribute/description)

It returns false if space explicitly required with print, true otherwise.

Example

Live Demo

Output :

Name of the file:  foo.txt

Closed / not :  False

Opening / mode :  wb

Soft space / flag :  0