jeudi 23 novembre 2017

Does Python encourage to use Arrow anti-pattern?

I’m C programmer and I used to avoid Arrow anti-pattern. Recently I’ve started coding in Python and it seems to me that Python language by itself encourage to use Arrow anti-pattern, because:

  1. The ‘with’ statement adds a level of indentation for the part of the code that uses specified resources.
  2. Indentations instead of braces to define suite (a block of code) makes code with a few nested levels shorter so more attractive to use.
  3. EAFP (Easier to ask for forgiveness than permission) leads to many ‘try’ and ‘except’ statements so more code is indented.
  4. The ‘else’ statement after ‘try’ and ‘except’ statements causes that more code is indented.
  5. The ‘else’ statement after ‘for’ statement causes that more code is indented.

Is Arrow still an anti-pattern in python?

Aucun commentaire:

Enregistrer un commentaire