问题描述
当我开始使用python进行编码时,这两件事让我感到惊讶。
1.我的代码与标签和
空格的组合不一致缩进。甚至线看起来都是预期的,但事实并非如此。
2. python需要传递self所有实例方法
我错过了:经常。 :)
When I started coding in python, these two things surprised me.
1. my code is inconsistently indented with the combination of tabs and
spaces. Even lines looked intended, but it is not.
2. python requires to pass "self" to all instance methods
and I missed ":" often. :)
推荐答案
即使是标准的编辑器Idle试图猜测这个意图,所以这个
从来都不是我的问题。虽然这些天我经常使用PyDev。
Even the standard editor Idle tries to guess the intendation, so this
was never a problem for me. Though these days I use PyDev a lot.
许多编辑通过
帮助你完成这些不必要的事情自动完成可能值得一看合而为一。
A lot of editors help you with these ''unnecessary'' things by
auto-completion might be worth looking into one.
经过5年的蟒蛇滥用后仍然这样做:-)
-
mph
Still do after 5 years of python abuse :-)
--
mph
你必须输入不一致。
即使我以前使用过记事本也没有遇到过这样的问题。
You must type inconsistently.
I never had such a problem even when I used to use Notepad.
谁使用方法?
Who uses methods?
尝试使用类似Seed7的东西,你必须使用then与
" if"和做与同时和结束在每个街区。也许你会
来欣赏重要的空白和:。
Try using something like Seed7, where you have to use "then" with
"if" and "do" with "while" and "end" in every block. Maybe you''ll
come to appreciate significant whitespace and ":".
谁使用方法?
Who uses methods?
这是个玩笑吗?
有哪些替代方案?
Is this a joke ?
What are the alternatives ?
尝试使用像Seed7这样的东西,你必须使用then与
" if"和做与同时和结束在每个街区。也许你会
来欣赏重要的空白和:。
Try using something like Seed7, where you have to use "then" with
"if" and "do" with "while" and "end" in every block. Maybe you''ll
come to appreciate significant whitespace and ":".
我看到了OP的重点。难道不能将新线用作
'''''的等价物,例如,你觉得这很难读:
如果a == 3
do_something()
如果a == 3:do_something()
当然,应该很容易由编译器解析。
Yves。
这篇关于python新手:一些惊喜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!