0

Is it possible to create an extension method in Python for datetime objects? I.e. I would like to create a date date = datetime.datetime(2022, 2, 2) and use my extension method which will do sth with that date by simply typing date.my_extension(args). Is it possible and if not, what is the best alternative for that?

3
  • Did you read stackoverflow.com/questions/352537/… and stackoverflow.com/questions/192649/… already? Commented Jun 10, 2022 at 16:34
  • 1
    Why not just write a function and use it like my_extension(date, args)? What exactly are you trying to achieve? I sense an XY problem. Commented Jun 10, 2022 at 16:35
  • you make a subclass of it and add whatever you want to it Commented Jun 10, 2022 at 16:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.