使用 Python 进行 Web 编程有什么好处?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/452305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the benefits of using Python for web programming?
提问by jjclarkson
What makes Python stand out for use in web development? What are some examples of highly successful uses of Python on the web?
是什么让 Python 在 Web 开发中脱颖而出?在网络上非常成功地使用 Python 的例子有哪些?
回答by Harper Shelby
Djangois, IMHO, one of the major benefits of using Python. Model your domain, code your classes, and voila, your ORM is done, and you can focus on the UI. Add in the ease of templating with the built-in templating language (or one of many others you can use as well), and it becomes veryeasy to whip up effective web applications in no time. Throw in the built-in admin interface, and it's a no-brainer.
恕我直言,Django是使用 Python 的主要好处之一。为您的域建模,为您的类编写代码,瞧,您的 ORM 已完成,您可以专注于 UI。添加在缓解与模板化的内置模板语言(或其他许多人,你可以使用,以及之一),它变得很容易掀起有效的Web应用程序在任何时间。加入内置的管理界面,这很容易。
回答by Greg Hewgill
Certainly one successful use of Python on the web is Google App Engine. Site authors write code in (a slightly restricted subset of) Python, which is then executed by the App Engine servers in a distributed and scalable manner.
当然,在网络上成功使用 Python 的是Google App Engine。网站作者使用 Python(稍微受限的子集)编写代码,然后由 App Engine 服务器以分布式和可扩展的方式执行。
回答by jfs
"Python is fast enough for our site and allows us to produce maintainable features in record times, with a minimum of developers," said Cuong Do, Software Architect, YouTube.com.
YouTube.com软件架构师 Cuong Do 说:“Python 对我们的网站来说足够快,并且允许我们以创纪录的时间生成可维护的功能,并且开发人员最少。”
回答by Simon Willison
YouTube uses a lot of Python and is probably the best example of a Python success story.
YouTube 使用了大量 Python,这可能是 Python 成功故事的最佳范例。
A great example of a Django success story is the Washington Post, who recently shared a big list of applications they have developed:
Django 成功故事的一个很好的例子是华盛顿邮报,他们最近分享了他们开发的大量应用程序:
http://push.cx/2009/washington-post-update
http://push.cx/2009/washington-post-update
www.lawrence.comand www.ljworld.comare two of the first sites to use Django (before it was even open source).
www.lawrence.com和www.ljworld.com是最早使用 Django 的两个站点(在它甚至开源之前)。
djangositeoftheweek.comhas a bunch of good case studies.
djangositeoftheweek.com有很多很好的案例研究。
www.everyblock.comis another great example.
www.everyblock.com是另一个很好的例子。
Finally, http://www.djangosites.org/links to nearly 2,000 other Django powered sites.
最后,http://www.djangosites.org/链接到近 2,000 个其他由 Django 驱动的站点。
回答by Cleante Constant
Furthermore,
此外,
Python is both strong in web and in data analytics and machine learning. For example scikit, sci-py and numpy are very strong. In some cases, it can be very interesting to have the both elements on the same server.
Python 在 Web 以及数据分析和机器学习方面都很强大。比如scikit,sci-py和numpy都很强。在某些情况下,将这两个元素放在同一台服务器上会非常有趣。
For example http://rankmytweet.comuses this a lot.
回答by Bleadof
Short anwser: the diversity of tools readily available and freedom of choice.
简短的回答:现成的工具的多样性和选择的自由。
This sounds like a simple question but which it really isn't. While Python is very good for web development and this has been shown by the, oh so famous, Google App Engine, Ploneand Django. One has to point out that the development way in Python requires a lot more from the developer than PHPbut it gives a lot more to the mix as well.
这听起来像是一个简单的问题,但实际上并非如此。虽然 Python 非常适合 Web 开发,这已经被非常有名的Google App Engine、Plone和Django所证明。必须指出,Python 中的开发方式对开发人员的要求比PHP多得多,但它也为混合提供了更多。
The entry level on actually producing something is higher. This is because there are bunch of different tools for doing web development with Python. Choosing the web development framework can be a hard decision for an inexperienced developer.
实际生产东西的入门级别更高。这是因为有很多不同的工具可以使用 Python 进行 Web 开发。对于没有经验的开发人员来说,选择 Web 开发框架可能是一个艰难的决定。
Having a lot of different tools is a two edged sword. To some extent it brings you the freedom of choice to pick the one you might want but then again how do you really know which one is good for what you're doing. This brings me to my point. Python stands out from the mass by not having a standard or de facto web development library. While this is pretty much against the principle of having only one simple way of doing on thing it also brings us a wide variety of different tools with different kind of design choices. At first this might feel very frustrating because it would be so much easier if somebody had made the choice for you but now that you're left to make the choice you actually might have to think about what you're doing and what would fit. ...or you might just end up picking one and blowing your head off after you've realized that you made the wrong choice. Anyway you end up, you've made the choice and no one else.
拥有许多不同的工具是一把双刃剑。在某种程度上,它为您提供了选择您可能想要的选项的自由,但话说回来,您如何真正知道哪个适合您正在做的事情。这让我明白了我的观点。Python 因没有标准的或事实上的 Web 开发库而脱颖而出。虽然这几乎违背了只有一种简单的处理方式的原则,但它也为我们带来了具有不同类型设计选择的各种不同工具。起初这可能会让人感到非常沮丧,因为如果有人为你做出选择会容易得多,但现在你要做出选择,你实际上可能不得不考虑你在做什么以及什么适合你。...或者你可能最终会选择一个然后在你之后吹你的头' 我意识到你做了错误的选择。不管怎样,你最终做出了选择,没有其他人。
回答by Erik Engbrecht
As many have pointed out, Django is a great reason to use Python...so in order to figure out why Python is great for web development, the best bet is to look at why it is a good language to build a framework like Django.
正如许多人指出的那样,Django 是使用 Python 的一个很好的理由……所以为了弄清楚为什么 Python 非常适合 Web 开发,最好的办法是看看为什么它是一种构建像 Django 这样的框架的好语言.
IMHO Python combines the cleanest, or at least one of the cleanest, metaprogramming models of any language with a very pure object orientation. This not only makes it possible to write extremely general abstractions that are easy to use, but also allows the abstractions to combine relatively cleanly with others. This is harder to do in languages that take a code-generation based approach to metaprogramming (e.g. Ruby).
恕我直言,Python 结合了任何语言中最干净的,或者至少是最干净的元编程模型之一,以及非常纯粹的面向对象。这不仅使编写易于使用的极其通用的抽象成为可能,而且还允许这些抽象与其他抽象相对干净地结合在一起。这在采用基于代码生成方法进行元编程的语言(例如 Ruby)中更难做到。
回答by Ryan
GNU Mailman is another project written in python that is widely successful.
GNU Mailman 是另一个用 python 编写的项目,它获得了广泛的成功。
回答by Aaron Maenpaa
回答by Javier
Dynamic languages are in general good for web apps because the speed of development. Python in particular has two advantages over most of them:
由于开发速度快,动态语言通常适用于 Web 应用程序。与大多数相比,Python 尤其有两个优势:
- "batteries included" means lotsof available libraries
- Django. For me this is the only reason why i use Python instead of Lua (which i like a lot more).
- “包含电池”意味着很多可用的库
- 姜戈。对我来说,这是我使用 Python 而不是 Lua(我更喜欢 Lua)的唯一原因。