Live data from Hacker News

Ask HN: Best Python web framework

news.ycombinator.com

71–80 of 110 posts

Re: Ask HN: Best Python web framework

#71
post #19

(Full disclosure: I'm a member of Django's core team) There's no single "best" for every application. One-size-fits-none. One of Django's strengths is in the fact that parts of the framework come off easily when they no longer serve your needs. If the ORM is no longer working for you, you can use SQLAlchemy or write raw SQL. Authentication no longer working for you? Write your own or use a 3rd party one. Et cetera. T…

I think another major strength of Django is its documentation. The docs for Django are some of the best I've ever seen for any open source project (or even commercial software for that matter). I don't see this mentioned often when people are comparing frameworks, but it's a big part of what made me choose Django in the first place.

Re: Ask HN: Best Python web framework

#72
BlueberryPy author here. Allow me to plug CherryPy and my micro-framework built on top of CherryPy called BlueberryPy.

Here's my answer on stackoverflow early last year when someone asked for a CherryPy vs Flask comparison. I believe all the points still stand and still represent CherryPy's strengths.

1. Simplicity. Controller object trees more or less equal to how you would define your URLs. 2. Flexibility. In case you don't like how the URLs are defined by default, you can use routes or methods to expose your URL handlers, which are just as easy. 3. Tools. CherryPy isn't religious about WSGI, though it's 100% compatible with the WSGI spec, the recommended approach is to use Tools. They are simple to make and use, and the way they are wired to the request is a lot more efficient than WSGI, which typically a request has to pass through whether or not that particular WSGI middleware is relevant. (Unless you use a framework where each URL handler is a WSGI application, but wiring up WSGI apps are still annoying). There are LOTS of them supplied by default that cover most of the use cases you can think of. 4. Plugins. For cross-cutting concerns, engine plugins are a much more granular, well-defined, and suitable way to deal with them as opposed to a WSGI app, which is typically the hammer people use to hammer in every screw these days. 5. Easy chunked responses. You just yield a string in the controller and that's it. Very useful for returning large documents in pieces. 6. Full-featured request and response objects. WebOb and CherryPy are about the only 2 frameworks that have comparably complete implementations of them, but I'd still choose CherryPy for the last reason: 7. Zero dependency on other packages. You won't bring in a dozen other libraries just to run a server. You just easy_install or pip install cherrypy and that's it.

Its WSGI server is also the canonical choice if you need a fast and stable pure Python WSGI server implementation. It's actually really really fast and stable:

    http://nichol.as/benchmark-of-python-web-servers


Now, I've been using CherryPy for about 5 years now and am still absolutely in love with it. I love it so much that I've decided last month to open source the micro-framework I've built on top of CherryPy called BlueberryPy:

    https://bitbucket.org/wyuenho/blueberrypy
It's basically a set of additional tools and plugins for CherryPy which give you an easier integration with SQLAlchemy, logging, Redis and Jinja2, webassets and various other goodies. It also comes with a project skeleton generator akin to many other frameworks out there but doesn't get in your way with the generated source files. All that BlueberryPy asks for is a configuration directory with a few correct YAML config files with a few keys pointing to a few classes in your package. Documentation is a little light but more will come soon enough as I find time to finish them up. Stay tuned :P

Re: Ask HN: Best Python web framework

#73
Richard Jones did a nice presentation about this in August 2011, comparing 10 Python frameworks along a lot of useful metrics (perf, simplicity, size, documentation, etc) by developing the same "hello world"-ish app in each one. He even scored them at the end.

The slides are at http://www.slideshare.net/r1chardj0n3s/web-microframework-ba... -- they don't seem to be loading inline now but the PDF download still works. Video of the talk is at http://www.youtube.com/watch?v=AYjPIMe0BhA .

Spoiler alert: the winner was bottle.py, by a nose.

Re: Ask HN: Best Python web framework

#74
post #64

web2py is great. Really. I'm quite sure some people are confusing web.py (toolkit behind reddit) and web2py - I know I was a couple of years ago. web2py is super complete, but doesn't get in your way, and doesn't require you to learn everything up front. It's DAL is much simpler (and in my opinion, much more effective) than an ORM -- but you don't have to use it. Its templating system is just plain python inside {{}}…

> I'm quite sure some people are confusing web.py (toolkit behind reddit) and web2py

Quite unlikely, they'd probably have far more praises for it if they did confuse them.

Re: Ask HN: Best Python web framework

#75
post #64

web2py is great. Really. I'm quite sure some people are confusing web.py (toolkit behind reddit) and web2py - I know I was a couple of years ago. web2py is super complete, but doesn't get in your way, and doesn't require you to learn everything up front. It's DAL is much simpler (and in my opinion, much more effective) than an ORM -- but you don't have to use it. Its templating system is just plain python inside {{}}…

reddit is built on pylons now. though there's way more code in it that has nothing to do with pylons.

Re: Ask HN: Best Python web framework

#76

Richard Jones did a nice presentation about this in August 2011, comparing 10 Python frameworks along a lot of useful metrics (perf, simplicity, size, documentation, etc) by developing the same "hello world"-ish app in each one. He even scored them at the end. The slides are at http://www.slideshare.net/r1chardj0n3s/web-microframework-ba... -- they don't seem to be loading inline now but the PDF download still works.…

It's worth noting that he's mainly concerned with publishing existing python apps he's already written as simple web services, not writing a complete web site from scratch. If you just look at the slides it's easy to miss this. This doesn't invalidate anything he says as such, but it's worth keeping this in mind if you're planning on doing a more complete web site.

Re: Ask HN: Best Python web framework

#77
post #60

Try Brubeck. It's a Python web framework built around Gevent, DictShield and ZeroMQ. It communicates with Mongrel2, it's web server, via ZeroMQ sockets so even the annoying design of WSGI is moved out of the way. It converts your blocking calls to nonblocking, has no spaghetti code filled with callback shenanigans, and can even generate a full REST API for you. https://github.com/j2labs/brubeck

I have used Pylons, Tornado and Brubeck in my projects over last couple of years and I must say if you are an experienced developer in Python, brubeck is a very good candidate. It is built for scalability in mind from day one. It is very light weight from code perspective and has a very transparent design which is very easy to understand to dive deeper if you need to.

Re: Ask HN: Best Python web framework

#78

Richard Jones did a nice presentation about this in August 2011, comparing 10 Python frameworks along a lot of useful metrics (perf, simplicity, size, documentation, etc) by developing the same "hello world"-ish app in each one. He even scored them at the end. The slides are at http://www.slideshare.net/r1chardj0n3s/web-microframework-ba... -- they don't seem to be loading inline now but the PDF download still works.…

Despite Jones' use of standardized metrics, in real world use of three of these frameworks I found that his scores indicated little about how effectively each performed.

Re: Ask HN: Best Python web framework

#79
I've been using Flask for my current project and I absolutely love it.

The project is a web interface for our library's digital archives (mostly audio and video assets, but also images and print documents). Version 1 of the project used php and mysql for the front end with python scripts handling the transcoding and metadata handling on the back end. For a variety of reasons the project got bloated to the point of being unmanageable. I decided I wanted a fresh start with a python framework and considered all the ones mentioned here.

I went with Flask because I wanted to leave the existing database structure in place and I wanted to err on the side of the framework doing too little instead of too much.

As a non-programmer (my job title says "audio engineer"), Flask was simple enough to understand, but did enough to make my life considerably easier. My one gripe is I think Flask-Login still has room for improvement, at least in terms of documentation. I've gotten it working good enough, but I still don't understand how credentials are passed around my application.

I'm sure other frameworks would have also gotten me to where I needed to be, but after working with Flask for a month or so, I'm not immediately reaching for something else.

Re: Ask HN: Best Python web framework

#80
post #47
post #36

Earlier quoted context omitted.

Disagree, Django Rest Framework and TastyPie make REST APIs effortless: write Django models, register them with the REST plugin, hook the plugin to your main URL structure. They're a really good example of how Django enables reuse. Implementation-wise they both hook into the model framework and the form framework, although you can swap out those parts if your data lives elsewhere.

I see what you're saying. But I disagree that: Database = Model = Resource

The parent comment was only pointing out how incredibly fast and easy it is to get started with TastyPie. The moment you decide to create an API resource that isn't a one-to-one mapping with a database table or Model, TastyPie is still able to come with you every step of the way.
Post reply on HN