0
There is, in the Python language (v3.6), some function that serves to display attributes and methods of an object, such as the console.dir()
in Javascript?
I would like to get an output similar to that of console.dir
in web browsers.
The function dir
of Python has a "messy" return, where a text denoting an array is returned, which does not indicate what is method and what is attribute, since such a return is in the same text style, and I would like each line to contain only one method/attribute, making it easier to understand and not get lost.
For example: In a scenario where an object manages/represents employees:
Fictitious attributes and methods:
- Dismiss: method of
- Hire: method
- Employees: attribute
As the function dir
python returns:
['demitir', 'contratar', 'funcionarios']
How I’d like you to return (more or less):
{
'demitir':'function...',
'contratar':'function...',
'funcionarios': 20
}
I’m open to suggestions from third-party libraries/resources. I don’t need it to be native, I just need it to work more or less like I described. Thank you.
Type the function
dir
?– Woss
@Andersoncarloswoss How can I format output? A complete mess comes out, both on Windows console and IDLE.
– Seu Madruga
Like a complete mess? The result is a list of attributes and methods. What exactly do you mean by "format" and why this is not described in the question?
– Woss