PynamoDB icon indicating copy to clipboard operation
PynamoDB copied to clipboard

[Feature] add __post_init__ method to allow any customization

Open MacHu-GWU opened this issue 3 years ago • 0 comments

WHY

Most of modern ORM or data class library support user custom "Post Initialization Hook" that allow user to run any code after the instance is initialized. By doing this, user can implement their own easily:

  • Write Procedure
  • Validation
  • Or any custom requirements

For example:

You should consider doing this too

HOW

I would recommend to just define an dummy function __post_init__ in your Model class and call this function at the end of your __init__ function HERE:

class Model:
    def __init__(self, ...):
        ... # your code
        self.__post_init__()

    def __post_init__(self):
        pass

MacHu-GWU avatar Aug 12 '22 17:08 MacHu-GWU