Is it possible to create the same class multiple times with user input in python 3.8?
For example I may write:
x = input('Enter an int:')
Is it possible to create x classes automatically. Not instances but actual classes?
Yeah why not...
>>> def mkClass(i):
... class mk:
... def __init__(self):
... self.val = i
... return(mk)
...
>>> ok = mkClass(7)
>>>
>>> a = ok()
>>> a.val
7
>>>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.