python新手:一些惊喜 [英] python newbie: some surprises

查看:97
本文介绍了python新手:一些惊喜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始使用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. :)

推荐答案

v4vijayakumar写道:
v4vijayakumar wrote:

当我开始在python中编码时,这些两件事让我感到惊讶。


1.我的代码与标签和

空格的组合不一致地缩进。甚至线看起来都是预期的,但事实并非如此。
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.



即使是标准的编辑器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.


2. python需要传递self所有实例方法
2. python requires to pass "self" to all instance methods



许多编辑通过

帮助你完成这些不必要的事情自动完成可能值得一看合而为一。

A lot of editors help you with these ''unnecessary'' things by
auto-completion might be worth looking into one.


>

我错过了:"经常。 :)
>
and I missed ":" often. :)



经过5年的蟒蛇滥用后仍然这样做:-)


-

mph

Still do after 5 years of python abuse :-)

--
mph


5月8日凌晨2点06分,v4vijayakumar< vijayakumar.subbu ... @ gmail.com>

写道:
On May 8, 2:06*am, v4vijayakumar <vijayakumar.subbu...@gmail.com>
wrote:

当我开始在python中编码时,这两件事让我感到惊讶。


1.我的代码不一致缩进制表符和

空格的组合。甚至线条看起来都有意,但事实并非如此。
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.



你必须输入不一致。


即使我以前使用过记事本也没有遇到过这样的问题。

You must type inconsistently.

I never had such a problem even when I used to use Notepad.


>

2. python需要传递self到所有实例方法
>
2. python requires to pass "self" to all instance methods



谁使用方法?

Who uses methods?


>

我错过了:经常。 :)
>
and I missed ":" often. :)



尝试使用类似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 ":".


Mensanator写道:
Mensanator wrote:

> 2。 python需要传递self所有实例方法
>2. python requires to pass "self" to all instance methods



谁使用方法?


Who uses methods?



这是个玩笑吗?

有哪些替代方案?

Is this a joke ?
What are the alternatives ?


>
>

>而我错过了:"经常。 :)
>and I missed ":" often. :)



尝试使用像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。
http ://www.SollerS.ca


这篇关于python新手:一些惊喜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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