编写Django应用程序时的缩进标准 [英] Indentation standards when writing django Application

查看:39
本文介绍了编写Django应用程序时的缩进标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用notepad ++作为编辑器,我发现使用制表符时遵循代码中的关系更加容易.

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-在django代码(制表符或空格)中放入缩进的标准是什么?

1- What is the standard when it comes to putting indentation in the django code (tabs or space)?

2-您是否建议使用非记事本++的代码编辑器?

2- Do you recommend a code editor other than notepad++?

推荐答案

一定要遵循PEP8(请输入空格!),并遵循django风格指南.我想这不是缩进规则,但是有间距规则和其他编码标准.

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

它使共享代码变得更加容易.每当我看到有人使用camelCase或InitialCaps作为方法,属性或变量时,都会使我和stackoverflow解析器感到困惑.

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:

  1. 型号名称为 InitialCaps
  2. 字段定义为 lower_case
  3. 模型之间的X个换行符
  4. 元类是在模型字段之后但在方法之前定义的,中间有一个空白行.
  5. 常见方法的排序,例如 __ init __ __ unicode __

这篇关于编写Django应用程序时的缩进标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆