473,789 Members | 2,559 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DOS, UNIX and tabs

Ben
Hi,

I have a python script on a unix system that runs fine. I have a python
script on a windows system that runs fine. Both use tabs to indent
sections of the code. I now want to run them on the same system,
actually in the same script by combining bits and pieces. But whatever
I try my windows tabs get converted to spaces when I transfer it to the
unix system and the interpreter complains that the indentation style is
not consistent throughout the file. Short of going through 350 lines of
code and manually replacing spaces with tabs what an I do? I'm thinking
there surely must be a simple solution I have missed here!

Cheers,

Ben

Dec 27 '06
35 2725
On 2006-12-28, Felix Benner <fe**********@i mail.dewrote:
I like using tabs. And the style guide doesn't give a reason
why one shouldn't and neither does the thread
http://www.python.org/search/hyperma...94q2/0198.html
in the archive. So what's the point in typing four spaces for
indentation instead of one tab?
So that the whole Python source tree is consistent.

--
Grant Edwards grante Yow! What I want to find
at out is -- do parrots know
visi.com much about Astro-Turf?
Dec 28 '06 #21
Marc 'BlackJack' Rintsch <bj****@gmx.net typed
In <en**********@r egistered.motza rella.org>, Felix Benner wrote:
>I like using tabs. And the style guide doesn't give a reason why one
shouldn't and neither does the thread
http://www.python.org/search/hyperma...94q2/0198.html in the
archive.
This is a religious issue
It is, because god itself used four spaces for indentation when he wrote
his "world" project in seven days ;)

--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
Dec 28 '06 #22
Steven D'Aprano wrote:
I don't know what "problems" with tabs you are talking about. I never have
problems with tabs. *Other people* who choose to use software that doesn't
understand tabs have problems.

I've spent a lot of time reading both sides of the tabs versus spaces
argument, and I haven't found anything yet that explains why tabs are, in
and of themselves, bad.
Indeed. In fact, I came to the conclusion several years ago that tabs
are in better for formatting code because then different people on the
team can have their preferred tabstop width, be it 8, 4, or 2 spaces.
Ironically, it has always seemed to me then that tabs are superior for
python editing, since mixing tabs and spaces in an environment like this
means that stuff won't run, whereas in C it'll still compile even if the
code looks awful.
-tom!

--
Dec 28 '06 #23
Steven D'Aprano wrote:
But I think we all agree that mixing tabs and spaces is A Very Bad Thing.
I like mixing tabs and spaces, actually. Tabs for indentation, and
additional spaces to make the code "look pretty". Somebody please tell
me why this is bad and I'll stop.

class Apple(object):
def contrived_examp le_function(sel f, argument1, argument2,
argument3, argument4):
print "hello, world"

Apparently, emacs in python mode follows this convention, too. I like it
because I get the best of both worlds: the only thing against using
tabs-only-indentation is that wrapping long lines can be quite ugly,
while space-only-indentation allows for beautifying it somewhat by
lining up the columns to match. Tabs+spaces allows the "lining up" with
spaces to be explicitly separate from indentation.

--
pkm ~ http://paulmcnett.com

Dec 30 '06 #24
"Ben" <Be************ *@gmail.comwrot e:
>
Great - that worked.Thanks!
Is that a general method in linux you can always use to redirect
standard output to a file?
Works in Windows, too.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 30 '06 #25
Paul McNett <p@ulmcnett.com typed
Steven D'Aprano wrote:
>But I think we all agree that mixing tabs and spaces is A Very Bad
Thing.

I like mixing tabs and spaces, actually. Tabs for indentation, and
additional spaces to make the code "look pretty". Somebody please tell
me why this is bad and I'll stop.

class Apple(object):
def contrived_examp le_function(sel f, argument1, argument2,
argument3, argument4):
print "hello, world"

Apparently, emacs in python mode follows this convention, too.
That doesn't seem like a standard settings to me. I can't remember
changing the indentation settings for python, nonetheless my gnu emacs
uses four spaces for indentation. Placing wrapped lines into ordered
columns is done by inserting additional spaces. This all happens
automatically; you never need to insert spaces manually...
I like it because I get the best of both worlds: the only thing
against using tabs-only-indentation is that wrapping long lines can be
quite ugly, while space-only-indentation allows for beautifying it
somewhat by lining up the columns to match.
Did you try to open your code files with another editor, which has a
different length for tabulator chars? It would look quite ugly, I
guess...

--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
Dec 30 '06 #26
Sebastian 'lunar' Wiesner wrote:
Paul McNett <p@ulmcnett.com typed
>Steven D'Aprano wrote:
>>But I think we all agree that mixing tabs and spaces is A Very Bad
Thing.
I like mixing tabs and spaces, actually. Tabs for indentation, and
additional spaces to make the code "look pretty". Somebody please tell
me why this is bad and I'll stop.

class Apple(object):
def contrived_examp le_function(sel f, argument1, argument2,
argument3, argument4):
print "hello, world"

Apparently, emacs in python mode follows this convention, too.

That doesn't seem like a standard settings to me. I can't remember
changing the indentation settings for python, nonetheless my gnu emacs
uses four spaces for indentation. Placing wrapped lines into ordered
columns is done by inserting additional spaces. This all happens
automatically; you never need to insert spaces manually...
I never tried emacs, but somebody once told me that if you have set
indentation-by-tab, it will indent with tabs but insert additional
spaces in wrapped lines to look pretty.

>I like it because I get the best of both worlds: the only thing
against using tabs-only-indentation is that wrapping long lines can be
quite ugly, while space-only-indentation allows for beautifying it
somewhat by lining up the columns to match.

Did you try to open your code files with another editor, which has a
different length for tabulator chars? It would look quite ugly, I
guess...
Actually, no. Everyone can choose their own number of spaces-per-tab and
it'll look right, as long as everyone uses a monospace font.

--
pkm ~ http://paulmcnett.com
Dec 30 '06 #27
In <ma************ *************** ************@py thon.org>, Paul McNett
wrote:
>Did you try to open your code files with another editor, which has a
different length for tabulator chars? It would look quite ugly, I
guess...

Actually, no. Everyone can choose their own number of spaces-per-tab and
it'll look right, as long as everyone uses a monospace font.
You never tried that with tabs plus additional spaces to line up e.g.
arguments that are broken across lines, right?

And there are a number of environments where you can't change the length
of a tab like email or terminals where code will be displayed from time to
time for example as diffs from a version control system.

Ciao,
Marc 'BlackJack' Rintsch
Dec 31 '06 #28
In message <pa************ *************** *@gmx.net>, Marc 'BlackJack'
Rintsch wrote:
In <ma************ *************** ************@py thon.org>, Paul McNett
wrote:
>Everyone can choose their own number of spaces-per-tab and
it'll look right, as long as everyone uses a monospace font.

You never tried that with tabs plus additional spaces to line up e.g.
arguments that are broken across lines, right?
I prefer a more two-dimensional layout, keeping consistent indentation. To
illustrate using the example from Paul McNett:

class Apple(object):
******* *def contrived_examp le_function \
(
self,
argument1,
argument2,
argument3,
argument4
) :
******* **** print "hello, world"
#end contrived_examp le_function
#end Apple

Dec 31 '06 #29
Marc 'BlackJack' Rintsch wrote:
Did you try to open your code files with another editor, which has a
different length for tabulator chars? It would look quite ugly, I
guess...
Actually, no. Everyone can choose their own number of spaces-per-tab and
it'll look right, as long as everyone uses a monospace font.

You never tried that with tabs plus additional spaces to line up e.g.
arguments that are broken across lines, right?
You must not understand what they're talking about, because it works
fine.

The example is this:

"""\
class Foo:
\tdef Function():
\t\tAnotherFunc tionThatTakesMa nyArguments(arg 1,
\t\t arg2,
\t\t arg3)
"""
And there are a number of environments where you can't change the length
of a tab like email or terminals where code will be displayed from time to
time for example as diffs from a version control system.
That's the point of doing it in this way with tabs to specify indent
level and spaces to specify tabular alignment.

Me, I could never get emacs's python stuff to work suitably so I just
use a Dead Simple Editor (SciTE) in which I use tabs exclusively;
continuation indents are always exactly one additional tab over the
thing that's being continued.

Perhaps interestingly, for development I have my editor set to show tabs
as fairly short, but my diff program shows them as eight characters. I
find that makes indentation changes easier to spot in the diffs.
-tom!

--
Jan 1 '07 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4063
by: Kayle | last post by:
For preservation of indentation when moving the C source file from Windows to Linux machine, what is the advice to format the code. Should the code formatted using spaces instead of tabs? When opened using nedit in Linux, the indentation was not preserved, or should we limit the length of each line ? Any advice on this ? Thanks
135
7531
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about which is better. It has become what's known as “religious war” — a heated fight over trivia. In this essay, i like to explain what is the situation behind it, and which is proper.
1
295
by: Ben | last post by:
Hi, I have a python script on a unix system that runs fine. I have a python script on a windows system that runs fine. Both use tabs to indent sections of the code. I now want to run them on the same system, actually in the same script by combining bits and pieces. But whatever I try my windows tabs get converted to spaces when I transfer it to the unix system and the interpreter complains that the indentation style is not consistant...
7
3759
by: Phil Reynolds | last post by:
I'm using a tab control in Access 2000, and the user requested to have buttons in the form header, instead of the built-in tabs (so that when they scroll down, they can still switch tabs). Now, this works fine. However, when I'm in Design View, I can't access the tabs without changing the tab control's Style back to Tabs. But I want to be able to place controls in that space at the top where the tabs used to be. But if I need to turn the...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9502
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10383
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10178
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9000
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4080
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.