Changes between Version 5 and Version 6 of ChimeraPythonStyle
- Timestamp:
- Feb 2, 2011, 11:33:11 AM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ChimeraPythonStyle
v5 v6 1 1 2 == Chimera Python Style Guide==2 == Chimera Python Styles == 3 3 4 There is no generally accepted convention for python coding style in Chimera. I follow an interpretation of the python style guidelines by Guido, see the snippet below and the full spiel at: http://www.python.org/dev/peps/pep-0008/4 There is specific convention for python coding style in Chimera. Developers are free to use a familiar coding style, so long as it is consistent. To follow a familar and consistent style, I've adopted the python style guidelines by Guido (see [http://www.python.org/dev/peps/pep-0008/ PEP8]). 5 5 6 My style is 4 spaces for each indentation level (no tabs). My .vimrc contains:6 The style is 4 spaces for each indentation level (no tabs). It can be coded into a .vimrc like so: 7 7 {{{ 8 " global settings9 set tabstop=410 set shiftwidth=411 set expandtab12 8 " python settings 13 9 autocmd BufRead,BufNewFile *.py set ft=python ai sw=4 ts=4 sta et fo=croql foldmethod=indent 14 10 }}} 15 11 16 It's possible to insert a mode line into each file to override usereditor settings. The first line of the file might contain something like this (which should work for both emacs and vim):12 It's also possible to insert a mode line into the first line of a python file to override any editor settings. The first line of the file might contain something like this (which should work for both emacs and vim): 17 13 {{{ 18 14 # -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=python:et:sw=4:ts=4:sts=4:fdm=indent:fo+=croql 19 15 }}} 20 16 21 Note that the encoding (coding) is utf-8 here, which is recommended for python 3.x, but earlier versions are recommended to use ISO-8859-1, so the PEP8 recommends a mode line like this:17 Note that the encoding (coding) is utf-8 above, which is recommended for python 3.x, while python 2.x recommends ISO-8859-1, e.g.: 22 18 {{{ 23 19 # -*- coding: ISO-8859-1; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=ISO-8859-1:ft=python:et:sw=4:ts=4:sts=4
![[Chimera Issue Tracking System]](/trac/chimera/chrome/site/chimera_logo.png)