Python 3使用/未使用的功能是什么? [英] What are the used/unused features of Python 3?

查看:75
本文介绍了Python 3使用/未使用的功能是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将一些网页设计作为一种爱好,主要目的是学习有趣的东西.学习Python当然很好,但是我发现进行Great Python Rewrite太晚了,所以我必须同时学习Python 3和2.6.

I've recently did some web design as a hobby with a primary motivation to learn interesting things. It was certainly nice to learn Python, but I found out there has just been a Great Python Rewrite too late, so I had to learn both Python 3 and 2.6 essentially.

我是一个新手,所以我希望人们分享他们认为Python 3的优势/劣势是从那些进行最终用户编程的人而不是语言设计师的角度来看的.我的问题将更多是人们实际上喜欢使用或回避无用或非蟒蛇性的东西.

I'm a newbie, so I'd like people to share what they think the strengths/weaknesses of Python 3 are from the perspective of those who do end-user programming rather than language designers. My question would be more of what people are actually liking to the point of using, or shunning as being unproductive or unpythonic.

对我来说,with语句是肯定的加号,而破坏print运算符肯定是负号.

For me, with statement is definite plus, while breaking print operator is definitely minus.

说明编辑:有很多帖子问人们应该学习Python 2还是3,还是有什么区别.我看到我的问题是不同的:出于各种原因而选择使用Python 3,但可能对哪种方法更好的人有意见.

Clarification edit: there are many posts that ask whether one should learn Python 2 or 3 or whether there is any difference. I see my question is different: the feedback from people who for whatever reason made the choice of using Python 3 but might have an opinion about what works better, what not.

另一个说明:答案中指出with被反向移植到2. *.抱歉.

Another clarification: It has been pointed in the answers that with is backported to 2.*. Apologies.

推荐答案

长处是字节和字符串之间的澄清.在您短暂的Python经验中,您有多少次与不清楚的UnicodeDecodeErrorUnicodeEncodeError混淆了?如果您从未遇到过unicode和字节串的麻烦,很有可能您使用的是纯ascii语言(英语?;)),但这通常是初学者最难掌握的概念. (顺便说一下,如果您仍然感到困惑,对于Python 2.x,此链接应该会 )

Well a strong point is the clarification between bytes and string. How many times in your short Python experience have you been confused with the unclear UnicodeDecodeError and UnicodeEncodeError? If you never had troubles with unicode vs bytestrings, well chances are that you are using an ascii-only language, (English? ;) ) but this is usually the concept which is the hardest to grasp for beginners. (by the way, if you're still confused, this link should help for Python 2.x)

我真的认为str和字节之间的区别是Python3.0的强项之一.阅读 PEP358 以获得正式说明,并阅读

I really think that this distinction between str, and bytes, is one of the strong points of Python3.0. Read PEP358 for the formal description, and the diveintopython class for something more end-user oriented. This new feature forces developers to maintain a clear distinction between unicode objects, and bytes objects which are encoded in a specific encoding. I believe that this change will help newcomers understanding more easily the difference between the two structures, and will help experienced developers using sane programming methods.

但是,当然,这种更改有其自身的不便之处:移植2.x应用程序是非常困难的,如果您还没有清楚地将Unicode和字节字符串分开的话,这些从str + unicode到str + bytes的更改将是最令人讨厌的更改.在您的2.x代码中.烦人,但很需要.

But of course this change has its own inconvenients: porting 2.x applications is quite difficult, and these str+unicode to str+bytes change is the most annoying thing to change if you are not already clearly separating Unicode and byte strings in your 2.x code. Annoying, but long-needed.

那些重大更改对很多用户来说很烦人,并且...对于重要的库/解决方案来说很烦人. Python2.x的当前力量是众多的第三方应用程序/模块:但是由于有时移植到Python3并非易事,因此那些第三方应用程序将需要一些时间来移植(并且因为2.x仍然是如果还活着,那么这些应用程序将需要维护两个版本:一个针对2.x客户端,一个针对3.x ...昂贵的维护!)明年,运行Python3的成熟应用程序的数量可能会相当多.低,因为与Python3兼容的第三方数量很少.但是,我再次强烈支持这些重大更改:您阅读过猴子,香蕉,Python(3)和消防水带物语? ;)

Those breaking changes look annoying to a lot of users, and... are annoying to implement for important librairies/solutions. The current force of Python2.x is the numerous third-party applications/modules: but because it is sometimes not-trivial to port to Python3, those third-party apps will need some time to be ported (and because 2.x is still alive, those applications will need to maintain two versions: one aimed to 2.x clients, and one to 3.x... costly maintenance!) For the next year, the number of fully-fledged application running Python3 will likely be quite low, because of the low number of Python3-compatible third parties. But again, I strongly support these breaking changes: have you read this Monkey, banana, Python(3) and fire hose tale? ;)

这篇关于Python 3使用/未使用的功能是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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