不同平台上的标签缩进? [英] Tab indentions on different platforms?

查看:63
本文介绍了不同平台上的标签缩进?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,

我似乎在运行我的python代码时遇到了问题,在Mac上,在Linux和Windows机器上写了

。看来这个问题必须与tab缩进有关,特别是我注意到我的代码将完全忽略try语句。
有人有类似的问题吗?


问候,


解决方案

12月29日上午9:51,xkenneth< xkenn ... @ gmail.comwrote:


我似乎遇到运行python代码的问题,在Mac和Linux和Windows机器上写的




那么*你有什么*问题?更重要的是,

你有什么问题*实际上有*


看来这个问题已经有了

使用tab indention,特别是我注意到我的代码将完全忽略try语句。
有人有过类似的问题吗?



是。


设置文本编辑器以(a)识别Tab和Shift-Tab键盘

分别作为缩进/ dedent输入;(b)每个缩进插入4个空格和

零标签字符。 IOW,源文件中没有tab字符




如果之后你还有问题,请再次询问,

以下信息:


1.重现问题的最短脚本文件 -

使用

print open(''problemdemo.py'',''rb'')。read()

显示内容(a),因为它出现在Mac上(b)

在将[how?]转移到Windows后将[how?]转移到Linux(c)


2.执行每个代码的结果三种环境

- 复制/粘贴实际输出,而非描述。


* xkenneth(12月28日星期五) 2007 14:51:04 -0800(太平洋标准时间))


我似乎遇到运行我的python代码的问题,写在

a Mac,Linux和Windows机箱。



你似乎遇到问题或者你有问题吗?


似乎问题必须使用tab indention,



为什么它看起来和看起来似乎是什么?


特别是我''我注意到我的代码将完全忽略try

语句。



语句永远不会被忽略:它们错误或者它们不会。


有没有人有过类似的问题?



如果一个特定的编辑器(注意,那不是一个OS

的东西!)显示缩进并不重要。如果您只使用标签或空格,那只是

罚款。我个人会去寻找空间因为:


1.我不喜欢我看不到的东西(控制人物)


2.我从来没有遇到太空问题,但很多都有标签

Thorsten


2007年12月29日星期六15:29:25 +0000, Thorsten Kampe写道:


我个人会去空间因为:


1.我不喜欢我看不到的东西(控制字符)



你可以看到空格而不是标签吗?你的编辑很奇怪。在我用过的所有

编辑器中,空格和制表符都显示为空的白色

空格。 (如果我将编辑器设置为使用彩色

背景,则为彩色空间。)


2.我从未遇到过问题有空格但有很多标签



我会在这个清单上询问人们对标签有什么问题。

(我已经完全了意识到混合标签和空格是一件糟糕的事情。)我已经有了b $ b一点运气得到任何答案,除了标签很糟糕,没什么?。


我只知道一些人遇到的两个问题,因为

一致地使用制表符而不是空格。


*有些新闻客户没有正确显示标签,因此难以直接将新闻阅读器中的代码复制并粘贴到您的来源中;


(但是当然如果你使用空格复制代码,并且每个缩进级别使用的空格数

字符与你的源代码不匹配,你会

有问题也是。)


*某些应用程序有帮助将标签转换为空格,因此意味着

当从它们复制代码时,你最终会得到空格而不是标签。


你对标签有什么问题这与错误的

应用程序或混合标签和空格的用户有关吗?


-

Steven


All,
I seem to be having problems with running my python code, written
on a Mac, on Linux and Windows boxes. It seems like the problem has to
do with tab indention, particularly I''ve noticed that my code will
completely ignore try statements. Has anyone had a similar problem?

Regards,
Ken

解决方案

On Dec 29, 9:51 am, xkenneth <xkenn...@gmail.comwrote:

I seem to be having problems with running my python code, written
on a Mac, on Linux and Windows boxes.

So *what* problems do you seem to be having? More to the the point,
what problems are you *actually* having?

It seems like the problem has to
do with tab indention, particularly I''ve noticed that my code will
completely ignore try statements. Has anyone had a similar problem?

Yes.

Set up your text editor to (a) recognise Tab and Shift-Tab keyboard
inputs as indent/dedent respectively and (b) to insert 4 spaces and
zero tab characters per indent. IOW, don''t have tab characters at all
in your source files.

If after that you still have a problem, ask here again, with the
following information:

1. The shortest possible script file that reproduces the problem --
use
print open(''problemdemo.py'', ''rb'').read()
to show the contents (a) as it appears on the Mac (b) after
transferring [how?] to Linux (c) after transferring [how?] to Windows

2. The results of executing the code in each of the three environments
-- copy/paste of the actual output, not a description.


* xkenneth (Fri, 28 Dec 2007 14:51:04 -0800 (PST))

I seem to be having problems with running my python code, written on
a Mac, on Linux and Windows boxes.

You seem to have problems or you do have problems?

It seems like the problem has to do with tab indention,

Why does it seem and what does seem?

particularly I''ve noticed that my code will completely ignore try
statements.

Statements are never ignored: they error or they don''t.

Has anyone had a similar problem?

It doesn''t matter how a particular editor (note, that''s not an OS
thing!) displays indents. If you use only tabs or spaces that''s just
fine. I''d personally go for spaces because:

1. I don''t like things I cannot see (control characters)

2. I never had problems with spaces but plenty with tabs
Thorsten


On Sat, 29 Dec 2007 15:29:25 +0000, Thorsten Kampe wrote:

I''d personally go for spaces because:

1. I don''t like things I cannot see (control characters)

You can see spaces but not tabs? Your editor is pretty weird. In all the
editors I''ve every used, both spaces and tabs show up as empty white
space. (Or coloured space if I set the editor to use a coloured
background.)

2. I never had problems with spaces but plenty with tabs

Periodically, I ask on this list what problems people have with tabs.
(I''m fully aware that mixing tabs and spaces is a Bad Thing.) I''ve had
little luck getting any answer except "Tabs are bad, m''kay?".

I''m only aware of two problems that some people run into due to the
consistent use of tabs rather than spaces.

* Some news clients don''t display tabs correctly, thus making it hard to
copy and paste code direct out of the news reader into your source;

(But of course if you copy code using spaces, and the number of space
characters used per indent level doesn''t match your source code, you''ll
have problems too.)

* Some applications "helpfully" convert tabs into spaces, thus meaning
that when copy code from them, you end up with spaces instead of tabs.

What problems have you had with tabs that aren''t related to buggy
applications or users that mix tabs and spaces?

--
Steven


这篇关于不同平台上的标签缩进?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆