In the below code:
@classmethod
def find(self, id):
if isinstance(id, list):
rows = self.__table__().get_all(*id).run(self.__db__().conn)
result = []
for row in rows:
acategory = Category()
acategory.__dict__.update(row)
result.append(acategory)
return result
else:
adict = self.__table__().get(id).run(self.__db__().conn)
acategory = Category()
acategory.__dict__.update(adict)
return acategory
I have 2 questions:
1. Is there any better way to create attributes in an object without using
__dict__().update() or this is a correct approach?
2. Can we get the same result what for row in rows: block is producing without
killing the readability ?
To see the context, here is my source code
https://gitlab.com/aruprakshit/flask_awesome_recipes/blob/master/app/models/category.py
Thanks,
Arup Rakshit
[email protected]
--
https://mail.python.org/mailman/listinfo/python-list