473,789 Members | 2,479 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
"Erik Johnson" <ej at somewhere.com<t yped
>
"Ben Finney" <bi************ ****@benfinney. id.auwrote in message
news:ma******** *************** *************** *@python.org...
>"Sebastian 'lunar' Wiesner" <ba***********@ gmx.netwrites:
Just a tip for you: In python you never use tabs for indentation.

For some value of "you".
The python style guide [1] recommends four spaces per indentation
level.

[1] http://www.python.org/dev/peps/pep-0008/

It's not quite absolute on the topic:

For new projects, spaces-only are strongly recommended over tabs.

Even if were, read the Introduction. This is a coding standard
intended
to apply to code which is going to checked in as part of the core
python
build, not all Python! It's probably a pretty good standard to be
following in general, but come on...
It is, and especially the problems with tabs shows you, why it is good
practice to follow the standard in your own code, too...
--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
Dec 28 '06 #11
On Thu, 28 Dec 2006 09:26:28 +0100, Sebastian 'lunar' Wiesner wrote:
It is, and especially the problems with tabs shows you, why it is good
practice to follow the standard in your own code, too...
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.
--
Steven D'Aprano

Dec 28 '06 #12
Steven D'Aprano wrote:
On Thu, 28 Dec 2006 09:26:28 +0100, Sebastian 'lunar' Wiesner wrote:
>It is, and especially the problems with tabs shows you, why it is good
practice to follow the standard in your own code, too...

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.
You gave the reason in your post : because other people who are using
software that doesn't understand tabs as YOU expect them to have problems
with your code.

Tabs aren't a problem at all as long as nobody else than you edit your code.
Dec 28 '06 #13
Steven D'Aprano <st***@REMOVEME .cybersource.co m.autyped
On Thu, 28 Dec 2006 09:26:28 +0100, Sebastian 'lunar' Wiesner wrote:
>It is, and especially the problems with tabs shows you, why it is
good practice to follow the standard in your own code, too...

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.
Mmmh, maybe you never worked together with a team of other programmers
or have such a high position, that you can afford to ignore complaints
of your co-workers...

--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
Dec 28 '06 #14
Sebastian 'lunar' Wiesner schrieb:
Ben <Be************ *@gmail.comtype d
>I have a python script on a windows system that runs fine. Both use
tabs to indent sections of the code.

Just a tip for you: In python you never use tabs for indentation. The
python style guide [1] recommends four spaces per indentation level.

[1] http://www.python.org/dev/peps/pep-0008/
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?
Dec 28 '06 #15
Christophe Cavalaria schrieb:
Steven D'Aprano wrote:
You gave the reason in your post : because other people who are using
software that doesn't understand tabs as YOU expect them to have problems
with your code.

Tabs aren't a problem at all as long as nobody else than you edit your code.
Sorry, but that's a silly argument. With the same argument we should
stop using python alltogether since the usual MBA will understand
nothing but VBA.
Dec 28 '06 #16
Felix Benner wrote:
Christophe Cavalaria schrieb:
>Steven D'Aprano wrote:
>You gave the reason in your post : because other people who are using
software that doesn't understand tabs as YOU expect them to have problems
with your code.

Tabs aren't a problem at all as long as nobody else than you edit your
code.

Sorry, but that's a silly argument. With the same argument we should
stop using python alltogether since the usual MBA will understand
nothing but VBA.
No it isn't. If you have to work with some MBA that understands nothing but
VBA, why the hell are you writing Python code in the first place?

Dec 28 '06 #17
Felix Benner <fe**********@i mail.dewrote:
So what's the point in typing four spaces for indentation instead of one
tab?
So long as you always use only tabs there is no problem. So long as you
only use spaces there is no problem. If you mix tabs and spaces you can
introduce bugs. In particular, some people set their editor up to expand 1
tab to the next multiple of 4 spaces on their screen, but the usual
convention for tabs (and one that Python follows internally) is that tabs
expand to the next multiple of 8 spaces.

Usually when you mix spaces and tabs what you get either works the way you
intend, or it generates a syntax error. Once however when this recurring
question popped up I did a search through a load of Python files and
actually found once instance of some code which had been released and ran
whether tabs were expanded to 4 or 8 space boundaries. Reading that code it
was apparent that it had been written using 4 space tabs on the screen, but
that when it ran it did something different than had been intended.

So, given that mixing tabs and spaces is deadly choose one or the other and
stick to it. If you intend to work with other people then choose the same
convention as they use. If you are never going to work with others then use
whichever scheme makes you most comfortable.

Be careful as not all open source projects use the same convention: in
previous discussions on this newsgroup there were people arguing quite
strongly for using the tab convention. A straw poll indicated that there
was 1 open source project with 3 developers using tabs, and all other open
source projects use spaces only as the stated (but not always strictly
enforced) convention. Your experience may of course differ.

Of course nobody in their right minds actually types 4 spaces for
indentation: they use an editor where if the automatic indentation
isn't correct then hitting the tab key inserts the correct number of spaces
(and with luck where hitting the backspace key deletes back to the previous
tabstop).
Dec 28 '06 #18
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.
So what's the point in typing four spaces for indentation instead of one
tab?
You don't need to type four spaces. Every decent editor lets you use the
Tab key and inserts the proper amount of spaces for you. Same for
Backspace removing the proper amount of spaces to get to the previous
"tab stop".

There are plenty of "reasons" from both sides. This is a religious issue,
so please search the net for answers and don't start another
flam^H^H^H^Hdeb ate here. Please!

Ciao,
Marc 'BlackJack' Rintsch
Dec 28 '06 #19
On 2006-12-28, Steven D'Aprano <st***@REMOVEME .cybersource.co m.auwrote:
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.
They aren't. Using tabs isn't bad. Using both tabs and spaces
is bad, so the people managing the official Python source tree
picked one. Maybe they've got reasons for liking spaces over
tabs. Maybe they just flipped a coin. It doens't matter. What
matters is picking one and sticking with it.

--
Grant Edwards grante Yow! YOU'D cry too if it
at happened to YOU!!
visi.com
Dec 28 '06 #20

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
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
9971
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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();...
0
5406
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5541
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3678
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.