Функция dir() - удобна для получения списка атрибутов у любого объекта.
Ранее я писал про функцию __dir__() в модуле (не путайте её с переменной __all__(), которая указывает список объектов для импорта если встречается конструкция from module import *).
Скорее всего вы уже знаете как использовать функцию dir(). Любой объект может реализовать метод __dir__() чтобы указать список имеющийхся и динамических атрибутов. И функция dir() поможет получить список этих атрибутов.
>>> dir(str)
['__add__', '__class__', '__contains__', ...]
У этой функции есть еще один способ применения. Её можно вызвать без аргумента, и в таком случае она вернёт список имён в текущем неймспейсе.
>>> dir()
['__builtins__', '__doc__', '__file__', ...]
>>> def test():
>>> x = 1
>>> print(dir())
>>> test()
['x']
#basic#tricks
The Toronto HongKonger Dragon Boat team is now recruiting.
About the team:
We stand with HongKongers. Our goal is to regain HongKongers’ energy in Toronto and maintain our Lion Rock spirits high and strong in Canada through dragon boat racing, spreading the name of 'HongKongers' to more people.
coach – Matthew Ma:
👉🏻10 years of experience
👉🏻8 years as a certified dragon boat coach.
👉🏻was a part of the national team that represented Canada in the 13th and 14th World Dragon Boat Racing Championships in China and Thailand.
Facebook: https://www.facebook.com/profile.php?id=61554437804498&mibextid=LQQJ4d
Instagram: https://www.instagram.com/tohkdbt?igsh=MXF1NXRhMWdxYjEwcQ==
Email: [email protected]
Application: form at https://forms.gle/7HS5Uao5xFQd9isUA
#hongkonger#toronto#torontohongkonger
#drangonboatteam
#dragonboatrecruitment