Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (50.2k points)
I want to know that is it possible to view a .py as a file and present its class names, class methods, and variables as output?

1 Answer

0 votes
by (108k points)

What you can do is import the python module(that is .py file) and then call the dir python built-in function. Do not parse the input file as a text file. Let's suppose you want to list what you have in the os module you can do:

import os

dir(os)

 Want to be a Python expert? Join this Python Training course by Intellipaat to learn more.

Browse Categories

...