Listing object’s member variables in python

Today, I struggled trying to access amember variable of ASE‘s Atoms instance but I don’t know exactly the variable name. Printing out instance show some data but not what I need:


Atoms(symbols=’OH2′, positions=…, cell=[15.0, 15.0, 15.0], pbc=[True, True, True], calculator=SinglePointCalculator(…))

This can be easily found using the following statement:


__dict__.keys() is a python built-in feature to list instance/object’s member variable. Here is the result:


[‘info’, ‘adsorbate_info’, ‘_celldisp’, ‘_calc’, ‘arrays’, ‘_pbc’, ‘_cell’, ‘_constraints’]

And thus, all the member variables of an object is shown!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s