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 35 2721
I've found the unexpand command, which seems to do the trick. However,
it outputs to standard output, and I haven't worked out yet how to
capture that output to a file...
Ben
Ben wrote:
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
On 2006-12-27, Ben <Be************ *@gmail.comwrot e:
I've found the unexpand command, which seems to do the trick. However,
it outputs to standard output, and I haven't worked out yet how to
capture that output to a file...
unexpand <file1 >file2
--
Grant Edwards grante Yow! Hey, LOOK!! A pair of
at SIZE 9 CAPRI PANTS!! They
visi.com probably belong to SAMMY
DAVIS, JR.!!
Great - that worked.Thanks!
Is that a general method in linux you can always use to redirect
standard output to a file?
Cheers,
Ben
Grant Edwards wrote:
On 2006-12-27, Ben <Be************ *@gmail.comwrot e:
I've found the unexpand command, which seems to do the trick. However,
it outputs to standard output, and I haven't worked out yet how to
capture that output to a file...
unexpand <file1 >file2
--
Grant Edwards grante Yow! Hey, LOOK!! A pair of
at SIZE 9 CAPRI PANTS!! They
visi.com probably belong to SAMMY
DAVIS, JR.!!
On 2006-12-27, Ben <Be************ *@gmail.comwrot e:
>>I've found the unexpand command, which seems to do the trick. However, it outputs to standard output, and I haven't worked out yet how to capture that output to a file...
unexpand <file1 >file2
Great - that worked.Thanks!
Is that a general method in linux you can always use to redirect
standard output to a file?
Yup. The "<" operator redirects stdin, the ">" operator
redirects stdout. "2>" redirects stderr.
--
Grant Edwards grante Yow! Let's go to CHURCH!
at
visi.com
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/
--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
"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.
--
\ "I filled my humidifier with wax. Now my room is all shiny." |
`\ -- Steven Wright |
_o__) |
Ben Finney
At Wednesday 27/12/2006 20:09, Ben Finney wrote:
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.
Of course you can do it anyway you like, but you should have a
*strong* reason for not following a *strong* recommendation.
(Just a note, you can use untabify.py (inside the Tools dir) to
convert tabs to spaces, instead of unexpand)
--
Gabriel Genellina
Softlab SRL
_______________ _______________ _______________ _____
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas
"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... If Guido really wanted this enforced across the
board he could simply call anything that doesn't meet this standard to the
letter a SyntaxError and just stop there. For example, the standard states:
- Imports should usually be on separate lines, e.g.:
Yes: import os
import sys
No: import sys, os
>>import sys, os
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: Sorry, only one module per import line!
I'm sure that's not Guido's intention. ;)
-ej
On Wed, 27 Dec 2006 20:15:33 +0100, Sebastian 'lunar' Wiesner wrote:
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/
[obligatory pot-shot in the never-ending spaces versus tabs war]
In Python, I frequently use tabs for indentation, and I never have any
trouble *except* when posting code to Usenet, where other people's news
readers can't cope with tabs.
But I think we all agree that mixing tabs and spaces is A Very Bad Thing.
--
Steven D'Aprano This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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.
|
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...
|
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...
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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...
|
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,...
|
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...
|
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 project—planning, coding, testing, and deployment—without 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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| | |