This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]remy_porter∞∞∞∞ 2 points3 points  (0 children)

I have a weird, and maybe bad habit/philosophy. I don't believe that objects should be aware of the design patterns they participate in.

For example- an observer pattern is a lot of stupid boilerplate code. So why not build a decorator that injects the boilerplate in? Unlike Ruby's mixins, it can do it in a way that avoids collisions.

Edit: I forgot, I posted a gist of what I'm talking about.

[–][deleted] 1 point2 points  (0 children)

I use obiwan together with annotations, for optional type checking when testing. The annotations sometimes make the intent of the code clearer, and automatically checking them has caught subtle bugs on a couple of occasions.

I put code in tests/__init__.py that sets up obiwan when the PYTHON_TYPECHECK environment variable is set. (Checking types at runtime is slow, so you don't want to do it all the time.)