Hi I have the below from which I am trying to pull data from Outlook using code obtained on StackOverflow.
Using the first loop, I am trying to gather all attributes available to the object.
Whilst running it I notice the absence of Name which is later called in the 2nd loop, I assume this is due to inheritance. Please can you assist me in finding all attributes available to a class?
import win32com.client,sys
o = win32com.client.gencache.EnsureDispatch("Outlook.Application")
ns = o.GetNamespace("MAPI")
adrLi = ns.AddressLists.Item("Global Address List")
contacts = adrLi.AddressEntries
numEntries = adrLi.AddressEntries.Count
print(type(contacts))
nameAliasDict = {}
attrs_ = dir(contacts)
for i in range(len(attrs_)):
print((attrs_[i]))
for j in contacts:
print(j.Name)
sys.exit()
Use the
super
anddir
built-in functions.super
refers to the instance of the mother class.dir
returns a list of the argument's attributes.Output:
The output list contains all the attributes that are defined in the mother class. It mostly contains attributes inherited from
object
(the attributes between double underscores).If you do not extend the class whose you want to know the attributes, just use
dir
on an instance: