geophysics / mtpy

collection of python tools for standard MT data processing
GNU General Public License v3.0
32 stars 32 forks source link

Tabs vs spaces #19

Open ghost opened 12 years ago

ghost commented 12 years ago

I see Jared added a whole bunch of tab characters the other day to setup.py (not sure where else)

It still runs for me, but that's just lucky. All advice is not to mix spaces with tabs, and pick one or the other and stick with it. http://stackoverflow.com/questions/119562/tabs-versus-spaces-in-python-programming

What are we using for indentation?

kujaku11 commented 12 years ago

Right, good spot. I've always used tabs for indentation cause it was how I was taught and its only one button push instead of 4. Those are my thoughts

On Fri, Nov 2, 2012 at 1:08 PM, nietky notifications@github.com wrote:

I see Jared added a whole bunch of tab characters the other day to setup.py (not sure where else)

It still runs for me, but that's just lucky. All advice is not to mix spaces with tabs, and pick one or other and stick with it. http://stackoverflow.com/questions/119562/tabs-versus-spaces-in-python-programming

What are we using for indentation?

— Reply to this email directly or view it on GitHubhttps://github.com/geophysics/mtpy/issues/19.

geophysics commented 12 years ago

Hey, folks! Sorry for being late: I was taught exactly the other way round: "Never ever use tabs..." Because tab sizes seem to be different between systems and editors and can/could cause trouble when porting code. I faced lots of problems with reading in e.g. Fortran files which contain tabs instead of spaces, but that may be a typical Fortran issue (Since the people I know are programming using spaces, I did not run into this with Python so far). Additionally, the famous PEP8 Python guideline recommends spaces ;-) !!!

In most editors there is an option "handle/replace tab as/by spaces" (e.g. Notepad++), so it's still just one click, but effectively ending up in 4 space characters in the code.

"Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out." (source unknown)

ghost commented 12 years ago

Well, I'm okay with tabs -- I've used expanded spaces up until now (i.e. hit Tab and the editor inserts 4 spaces, and hitting Tab or Shift+Tab on a selected line adds or removes 4 spaces of indentation. Easy to do in vim, notepad++, sublime text, spyder, probably gedit, kate.) -- but I can see the advantages, and you're doing the most work on it so your preference is what matters to me.

Everything I've looked at in mtpy so far has 4 spaces, no tabs. Maybe I missed some changes. But we don't want to mix them, especially not in the same file. The Python interpreter has a mode that some people may always run it in where a mix of tabs and spaces in a file raises a error, not just a warning. Anyway, I'd say if you're going to add tabs to a file, change the whole file's indentation to tabs at the same time. If we get a unanimous opinion on here (Lars?) I will use tabs on mtpy files from now on.

On 7 November 2012 16:53, kujaku11 notifications@github.com wrote:

Right, good spot. I've always used tabs for indentation cause it was how I was taught and its only one button push instead of 4. Those are my thoughts

On Fri, Nov 2, 2012 at 1:08 PM, nietky notifications@github.com wrote:

I see Jared added a whole bunch of tab characters the other day to setup.py (not sure where else)

It still runs for me, but that's just lucky. All advice is not to mix spaces with tabs, and pick one or other and stick with it.

http://stackoverflow.com/questions/119562/tabs-versus-spaces-in-python-programming

What are we using for indentation?

— Reply to this email directly or view it on GitHub< https://github.com/geophysics/mtpy/issues/19>.

— Reply to this email directly or view it on GitHubhttps://github.com/geophysics/mtpy/issues/19#issuecomment-10139009.

ghost commented 12 years ago

LOL. Look, as long as the rabbit doesn't bite my head off, I'm happy.

On 7 November 2012 18:21, Kent Inverarity kent.inverarity@adelaide.edu.auwrote:

Well, I'm okay with tabs -- I've used expanded spaces up until now (i.e. hit Tab and the editor inserts 4 spaces, and hitting Tab or Shift+Tab on a selected line adds or removes 4 spaces of indentation. Easy to do in vim, notepad++, sublime text, spyder, probably gedit, kate.) -- but I can see the advantages, and you're doing the most work on it so your preference is what matters to me.

Everything I've looked at in mtpy so far has 4 spaces, no tabs. Maybe I missed some changes. But we don't want to mix them, especially not in the same file. The Python interpreter has a mode that some people may always run it in where a mix of tabs and spaces in a file raises a error, not just a warning. Anyway, I'd say if you're going to add tabs to a file, change the whole file's indentation to tabs at the same time. If we get a unanimous opinion on here (Lars?) I will use tabs on mtpy files from now on.

On 7 November 2012 16:53, kujaku11 notifications@github.com wrote:

Right, good spot. I've always used tabs for indentation cause it was how I was taught and its only one button push instead of 4. Those are my thoughts

On Fri, Nov 2, 2012 at 1:08 PM, nietky notifications@github.com wrote:

I see Jared added a whole bunch of tab characters the other day to setup.py (not sure where else)

It still runs for me, but that's just lucky. All advice is not to mix spaces with tabs, and pick one or other and stick with it.

http://stackoverflow.com/questions/119562/tabs-versus-spaces-in-python-programming

What are we using for indentation?

— Reply to this email directly or view it on GitHub< https://github.com/geophysics/mtpy/issues/19>.

— Reply to this email directly or view it on GitHubhttps://github.com/geophysics/mtpy/issues/19#issuecomment-10139009.

ghost commented 12 years ago

(Didn't see Lars' comment before I posted. Whatever you guys decide. At the moment status quo in the codebase is definitely 4 spaces, and pretty much every non-trivial Python project I've ever seen is 4 spaces.)

kujaku11 commented 12 years ago

4 spaces it is then.

Seems to be the way to go. I think I confused myself with hitting the tab key and actually putting \t in the file instead of 4 spaces.

On Wed, Nov 7, 2012 at 9:08 PM, nietky notifications@github.com wrote:

(Didn't see Lars' comment before I posted. Whatever you guys decide. At the moment status quo in the codebase is definitely 4 spaces, and pretty much every non-trivial Python project I've ever seen is 4 spaces.)

— Reply to this email directly or view it on GitHubhttps://github.com/geophysics/mtpy/issues/19#issuecomment-10140587.