which python framework to use?

2019-03-26 05:42发布

I'm looking for a framework which is appropriate for beginners (in Python and web development).

I already found out about Django and web.py. I think that one of the most important things for me is good documentation.

Thanks for the help, Dan

10条回答
太酷不给撩
2楼-- · 2019-03-26 05:42

You should also take a look at web2py which has good docs and is a very nice framework for building wep apps.

查看更多
小情绪 Triste *
3楼-- · 2019-03-26 05:45

DanJ, here's a pretty good list of all the known Python frameworks: http://wiki.python.org/moin/WebFrameworks

I would recommend looking at the wikipedia articles for Django, Turbogears, Pylons, etc. [I wrote an article on web.py once, but it got deleted :-(] They explain the philosophical and component differences between the frameworks pretty well.

Personally, I like TurboGears a lot since it is based on well-known components, CherryPy (for web serving and URL routing), Kid (for templates), and SQLObject (for object-relational mapping). I like that they've resisted the urge to "roll your own" for all the components, and I feel that the result is very Pythonic and easy to get started with.

But you should look at some code samples and tutorials, and decide what suits you best.

查看更多
劳资没心,怎么记你
4楼-- · 2019-03-26 05:48

I've written web-apps with raw wsgi. Perhaps rolling out my own library at some point. I don't just like about large frameworks and such. I learned to hate http while writing in raw wsgi. You don't really like it after you realise how much stupid parsing and interpretation you need to upload a file.

Because of wsgi, python has tons of frameworks of different qualities. If you want to try my way, I'd guess you'd like to know werkzeug perhaps. It provides some things when you don't yet know how to do them. It only has perhaps too much of a 'framework' for me. In the end very well written framework ought exceed what I've written in wsgi though.

查看更多
贪生不怕死
5楼-- · 2019-03-26 05:55

I assume you are talking about a web framework. I have used CherryPy, and found it quite useful. Try using each one to code a simple solution, and see how much it lines up with your style of programming.

查看更多
地球回转人心会变
6楼-- · 2019-03-26 05:58

web.py?

It's extremely simple, and Python'y. A basic hello-world web-application is..

import web

 urls = (
     '/(.*)', 'hello'
  )

class hello:        
    def GET(self, name):
        i = web.input(times=1)
        if not name: name = 'world'
        for c in range(int(i.times)):
            print 'Hello,', name+'!'

if __name__ == "__main__": web.run(urls, globals())

..that's it.

I found Django forced a lot of it's own conventions and code layout, and I could never remember the middleware/shortcuts imports, and all the other "magic" that is pretty much required to write anything. I found it was closer to Ruby on Rails than a Python web-framework.

With web.py, you can write an entire, functioning web-application without using any of web.py's helper modules - the only thing you have to do is import web and setup the URLs, which is rather unavoidable. (the last line in the example runs the development web-server)

It has lots of stuff in it, like an database API, form helpers, a templating engine and so on, but it doesn't force them on you - you could do all your HTML output by print "Using <b>%s</b>" % (" string formating ".strip()) if you wished!

Oh, while I have emphasised the simplicity, web.py is what http://reddit.com is written in, so it's also proven very capable/reliable. Also, this post by the web.py author is a very good explanation of why I much prefer web.py over Django

查看更多
We Are One
7楼-- · 2019-03-26 06:02

Django is amazingly good. Guido uses it (working at Google). It's the main reason why i find myself working more in Python than in Lua.

查看更多
登录 后发表回答