Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get object attributes python

for att in dir(your_object):
    print (att, getattr(your_object,att))
Comment

python get attributes of object

getattr(object, 'attribute_name')
Comment

see attributes of object python

>>> class new_class():
...   def __init__(self, number):
...     self.multi = int(number) * 2
...     self.str = str(number)
... 
>>> a = new_class(2)
>>> a.__dict__
{'multi': 4, 'str': '2'}
>>> a.__dict__.keys()
dict_keys(['multi', 'str'])
Comment

python get attributes of object

field_name = "fullName"
print getattr(user, field_name) # prints content of user.fullName
Comment

python get object attributes

Use the built-in function dir()
Comment

PREVIOUS NEXT
Code Example
Python :: show all rows for dataframe 
Python :: how to append items to a list in python 
Python :: round off float to 2 decimal places in python 
Python :: train test split sklearn 
Python :: pyspark print a column 
Python :: python open file for reading and writing 
Python :: how to get input with python 
Python :: pyspark now 
Python :: Load dataset from seaborn 
Python :: python count variable and put the count in a column of data frame 
Python :: time difference between timestamps python 
Python :: python - count total numeber of row in a dataframe 
Python :: custom jupyter notebook 
Python :: convert np shape (a,) to (a,1) 
Python :: try except json decode error 
Python :: discord py check if user has permission return message if not 
Python :: tkinter window size 
Python :: cv2 copy image 
Python :: minmaxscaler python 
Python :: python string startswith regex 
Python :: python to mac executable 
Python :: merge dicts python 
Python :: custom position for axis matplotlib 
Python :: how to install tkinter in pycharm 
Python :: how to make python file executable 
Python :: python not equal multiple values 
Python :: random python between 0 and 1 
Python :: geopandas stack or concatenate dataframe together 
Python :: Aligning rotated xticklabels with their respective xticks 
Python :: python ordereddict 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =