I have defined a class and need most of its attributes handed over to a function for processing. So I thought instead of creating a huge mess and naming them all I'd do processSomething(vars(self))
and hand over a nice dictionary with all attributes and values.
But I found that almost all of the attributes are missing.
I have halted the code in the debugger and ran a few tests:
>>> vars(self).keys()
dict_keys(['date_expire', 'tokenUrl', 'settings', 'requestSession', 'ttlDays'])
These are 5. While I am expecting about 20 attributes, as per __slots__
definition of my class here:
__slots__ = (
'token', # the invitation-token to load the username with
'request', # the http-request which is currently being serviced
'inhibit',
#... many lines deleted
'templateObj', # an instance of myMail.template.Template
'emailBody', # what will be sent via SMTP
'warningsAr', # messages for the client
)
I can see the attributes in the debugger window and can access them directly. I have read the manual of vars() and could not find any switches. Interestingly, dir(self)
shows all attribute-names, but no values. So I cannot use that. But I thought vars and dir should show the same?
I guess I'll build a workaround, but I really want to understand what is happening here. Can you please help?