>>> 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'])
You may also find pprint helpful.
More Related Contents:
- Name class error
- Why is the id of a Python class not unique when called quickly?
- Saving and loading multiple objects in pickle file?
- How do I detect if the mouse is hovering over a button? PyGame button class is not displaying the text or changing colour on hover
- Which classes cannot be subclassed?
- Prevent creating new attributes outside __init__
- putting current class as return type annotation [duplicate]
- Why is a class __dict__ a mappingproxy?
- “__init__” vs “__call__” in python class
- Comparable classes in Python 3
- Class (Static) variables and methods in Python
- Using Properties in Python classes cause “maximum recursion depth exceeded” [duplicate]
- How do you change the value of one attribute by changing the value of another? (dependent attributes)
- TypeError: attack() missing 1 required positional argument: ‘self’
- Provide __classcell__ example for Python 3.6 metaclass
- What is the difference between super() with arguments and without arguments?
- Get the object with the max attribute’s value in a list of objects
- How to search and replace text in a file?
- How to access variables from different classes in tkinter?
- Converting int to bytes in Python 3
- Normalizing Unicode
- Accessing attributes on literals work on all types, but not `int`; why? [duplicate]
- Possibilities for Python classes organized across files? [closed]
- NameError: global name ‘xrange’ is not defined in Python 3
- Multiprocessing causes Python to crash and gives an error may have been in progress in another thread when fork() was called
- ‘utf-8’ codec can’t decode byte 0x92 in position 18: invalid start byte
- How to implement a binary search tree in Python?
- How to parallelize file downloads?
- Updating a value in a pandas dataframe in an iterrows loop
- return value from one python script to another