[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python refactoring question and create dynamic attributes

In the below code:

    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()
            return result
            adict = self.__table__().get(id).run(self.__db__().conn)
            acategory = Category()
            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 


Arup Rakshit
ar at