Indentation standards when writing django Application
I am using notepad++ as an editor, and I find that it is easier to follow relations in my code when I use tabs.
1- What is the standard when it comes to putting indentation in the django code (tabs or space)?
2- Do you recommend a code editor other t开发者_开发问答han notepad++?
Definitely follow PEP8 (spaces, please!) and also follow the django style guidelines. I suppose it's not an indentation rule, but there are spacing rules and other coding standards.
http://docs.djangoproject.com/en/dev/internals/contributing/#coding-style
It makes sharing code much easier. Whenever I see somebody using camelCase or InitialCaps for methods, attributes, or variables it confuses me and the stackoverflow parser.
Here are some examples from the coding guidelines page:
- Model names are
InitialCaps
- Field definitions are
lower_case
- X linebreaks between models
- Meta classes are defined after the model fields but before methods, with one blank line spacing.
- Ordering of common methods like
__init__
,__unicode__
Python PEP 8 encourages 4 spaces, no tabs.
Many editors support this, including: Vim, Emacs, Komodo, WingWare, and PyCharm to name just a few.
I should point out that I'm not specifically discouraging you from using tabs, but addressing your question regarding indentation standards.
Everyone is going to have a different opinion on text editors, so no point really in asking.
As for the spaces/tabs, python has PEP 8 which gives some general guidelines for coding in Python. The rule here is to indent using 4 spaces.
http://www.python.org/dev/peps/pep-0008/
As for editors - you might want to try out Editra (written in python).
精彩评论