问题
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
回答1:
I think Django has some of the best documentation of any project I've worked on. That's the reason we chose it over Turbogears two years ago, and it's been the best technology choice we've made.
回答2:
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
回答3:
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.
回答4:
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.
回答5:
You should also take a look at web2py which has good docs and is a very nice framework for building wep apps.
回答6:
You might want to look at Karrigell. It has multiple options for programming syntax, e.g. pure Python, pure HTML w/ Python scripts, combination, etc. I don't know how well it scales because I haven't used it for several years but it's good for getting your feet wet w/ web frameworks.
回答7:
Echoing the answer of few, I suggest Django. for some simple reasons:
- It follows standard MVC architecture.
- You can modularise your entire application right from db modeling.
- Extensive documentation and free online example/project based books available.
- Many open source web based projects for reference available.
回答8:
Wekrzeug is worth mentioning as well. It's not a full stack web framework. It is a low level WSGI framework. (30 Minute Wiki Screencast)
回答9:
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.
回答10:
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.
来源:https://stackoverflow.com/questions/202939/which-python-framework-to-use