2015-04-04 22:05:30 +01:00
|
|
|
# test builtin dir
|
|
|
|
|
|
|
|
# dir of locals
|
|
|
|
print('__name__' in dir())
|
|
|
|
|
|
|
|
# dir of module
|
|
|
|
import sys
|
2017-02-14 20:27:44 +00:00
|
|
|
print('exit' in dir(sys))
|
2015-04-04 22:05:30 +01:00
|
|
|
|
2016-12-20 03:08:27 +00:00
|
|
|
# dir of type
|
|
|
|
print('append' in dir(list))
|
|
|
|
|
2015-12-29 04:03:15 +00:00
|
|
|
class Foo:
|
|
|
|
def __init__(self):
|
|
|
|
self.x = 1
|
|
|
|
foo = Foo()
|
|
|
|
print('__init__' in dir(foo))
|
|
|
|
print('x' in dir(foo))
|
|
|
|
|