5 ms·
make sure you use tabs to format all of your Python code I disagree. Idiomatic Python uses 4 spaces per indent. Either solely use tabs or solely use spaces, t
by Luyt 16y ago
make sure you use tabs to format all of your Python code
I disagree. Idiomatic Python uses 4 spaces per indent.
Either solely use tabs or solely use spaces, they don’t work well together, at least in my experience
Mixing tabs and spaces is indeed very unwise. You can run Python with the -tt option to make sure you're consistent.
Read Style Guide for Python Code for more advice on this front
I agree ;-) The author probably refers to PEP8, http://www.python.org/dev/peps/pep-0008/ http://www.python.org/dev/peps/pep-0008/
- sahillavingia 16y agoAh yes, I'll read more into it! thanks :)
- shortlived 16y agoI was fixing a makefile the other day with a coworker and it ended up being an indentation issue. And then we asked out loud why anyone would repeat this hell again... Now, I am not a python programmer, but I am interested to learn more about how the structure via indentation how worked out for the language.
- bwooceli 16y agoCould not agree more!!!! If you're a vimmy, be sure to add this friendly helper into your .vimrc :set tabstop=4 :set shiftwidth=4 :set expandtab
- mattdawson 16y agoOr, if you only want to use these settings for python files, create a ~/.vim/ftplugin/python.vim file. Mine looks like this: setlocal tabstop=4 setlocal softtabstop=4 setlocal shiftwidth=4 setlocal textwidth=80 setlocal smarttab setlocal expandtab setlocal smartindent
- whimsy 16y agoToday I learned... Thanks. It looks like ftplugin is a native vim extension - is that correct?
- mattdawson 16y agoI'm a bit late in responding, but yes, it's a native vim extension. To make sure your plugins are loaded automatically, put filetype plugin on in your .vimrc.