print(dir(Person)) Try it Yourself » Definition and Usage Thedir()function returns all properties and methods of the specified object, without the values. This function will return all the properties and methods, even built-in properties which are default for all object. Syntax dir(object) Parameter Values ParameterDescription objectThe object you want to see the vali...
Python dir FunctionLast modified April 11, 2025 This comprehensive guide explores Python's dir function, which returns a list of valid attributes for an object. We'll cover basic usage, custom objects, and practical examples of object introspection. ...
If the object has a method named __dir__(), this method will be called and must return the list of attributes. This allows objects that implement a custom __getattr__() or __getattribute__() function to customize the way dir() reports their attributes. If the object does not provide...
The dir() function is a built-in function in Python that returns a list of names in the current local scope or a specified object. It is used to introspect Python objects and find out what methods or attributes they have. When called without any arguments, the dir function in python retu...
print("dir class A:", dir(A)) print("dir class A1:", dir(A1)) a = A1() print("dir object a(A1):", dir(a)) print("dir function a.a:", dir(a.a)) print("dir current file:", curModuleDir) 4.2.方法二:import当前module ...
dir function a.a: ['__call__', '__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__func__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__red...
If the object has a method named __dir__(), this method will be called and must return the list of attributes. This allows objects that implement a custom __getattr__() or __getattribute__() function to customize the way dir() reports their attributes. ...
【Python】dir函数 & help函数 岸边散步的鱼儿 不见高山,不显平地 1 人赞同了该文章 随手记一些自己学到的知识 dir函数 作用:返回模块或类所包含的全部程序单元(变量、函数、类和方法等),也就是可以看见包里包含什么内容 比如: import torch output = dir(torch) print(output) 输出: ['AVG', 'Aggregation...
If the object has a method named__dir__(), this method will be called and must return the list of attributes. This allows objects that implement a custom__getattr__()or__getattribute__()function to customize the waydir()reports their attributes. ...
print("dir class A1:", dir(A1)) 15 a=A1() 16 print("dir object a(A1):", dir(a)) 17 print("dir function a.a:", dir(a.a)) 18 测试结果: dir without arguments: ['A','A1','__builtins__','__doc__','__file__','__name__','__package__'] ...