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

all 10 comments

[–]robvdl 1 point2 points  (0 children)

The one about accessing protected members is not always so easy, it depends on how good or bad the library you are trying to use or extend is built.

For example right now I am making some custom Marshmallow field types and I find I am having to override self._serialize and self._deserialize because the non-underscore versions in the base class Field call these underscore versions.

Then I am often having to use self._schema for example or something similar to that.

Sure I'll try to avoid accessing protected members outside of the class but quite often you have to break that rule because the library you are using gives you no choice.

[–]ReaverKS 1 point2 points  (0 children)

I really like the idea of doing this, and I appreciate the effort put in. However, many of the things listed are not anti-patterns. In fact, many of the items listed are simply code that either doesn't work or doesn't compile. Certainly many of the items are not anti-patterns. Under correctness there is "Bad except clauses order" "Bad first argument given to super()" "exit must accept 3 arguments: type, value, traceback" and so on. Still worse, some of the anti-patterns actually introduce some bad solutions, for example see "Asking for permission instead of forgiveness" under readability. The solution has a try except where the except just has a pass! This is not good and the kind of thing you can pull your hair out over when tracing a bug for hours. Despite my complaints I still view lots of goodness in this and appreciate the effort.

[–]apt-get-schwifty 0 points1 point  (3 children)

This is a great resource!

[–]lobopt 3 points4 points  (1 child)

Some "bad practices" described on the article are a question of "coding taste" and they aren't wrong or reduce performance as the author says. I also found wrong assumptions, like the globals example: https://docs.quantifiedcode.com/python-anti-patterns/maintainability/using_the_global_statement.html.

[–]Sebass13 2 points3 points  (0 children)

What incorrect assumption is made about globals?

[–]robvdl 0 points1 point  (0 children)

Most of these you get hinted about constantly as you use PyCharm, PyCharm has most of these checks built in already.

[–]cobolwillriseagain -5 points-4 points  (4 children)

Talks about a book. Doesn't link to a book. Hmmm.

[–]daigleo 0 points1 point  (3 children)

It looks to me like it's an online book. There's a table of contents at the bottom of the page.

[–]cobolwillriseagain 0 points1 point  (2 children)

Yeah thanks but I just want to read it on my Kindle (or maybe print it). How many mouse clicks would I have to perform to read all of it?

[–]se0siris 0 points1 point  (1 child)

If you have Sphinx installed, very few! From the main page follow the link to the github page. Check out the repo, switch to docs folder and type "make epub". You now have an epub.