Live data from Hacker News

A Beginner’s Introduction to Python Web Frameworks (2018)

stxnext.com

141–150 of 168 posts

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#141
post #68

I primarily use Flask for my research project. It was quick to pick up and honestly, I like a more barebones style - one of the reasons I use Sublime Text over IDEs. Plus Miguel Grinberg's tutorial is fantastic at getting you on your feet (though I'm still sour over changes compared to his original tutorial, more because its made it difficult to onboard new developers). However, Pyramid's made some of the coolest shi…

For once I thought, you're bluffing, and the shirts were of some Rock band, but it's indeed for the web framework "Pyramid" xD

I met them back in 2015 at PyCon and they said that they loved the art design of Iron Maiden shirts and Eddie, so since it was their product, they decided that'd make it how they wanted

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#142

Earlier quoted context omitted.

Same can be said for any system, regardless of the language. Unless you’re able to create an artifact like a single executable or a Jar but you still need to supervise those and keep them running.

Say what you want to about PHP, but when it comes to deployment it’s hard to beat.

Only for web apps that don't get much traffic. Constant hand-tuning of PHP-FPM configs isn't fun.

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#143
post #123

Are any of these extremely good compared to a framework not written in Python? For example compared to Rails or Phoenix?

They are probably not much better as frameworks than Rails or Phoenix but using Python allows you to import a lot of things from the Python ecosystem. (eg http://www.developintelligence.com/blog/python-ecosystem-201... )

Yeah. I asked because I really like Python's libraries in general, but I found Flask to be so-so, and I just recently worked on a large project in Django, which I hated. I was hoping there was some kind of up-and-coming framework in Python I didn't know about.

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#144

Of these frameworks, Pyramid is the only one I know of that uses the concept of traversal. Traversal is an elegant way to tame big projects. Whenever I look at a web framework, I look for traversal and I'm always a little disappointed to see it's missing. Traversal means the framework treats each path segment in the URL as a possible branch in a tree of resources provided by the app. After completing traversal, the f…

Maybe a semi-realistic example would help us understand what you mean by the path segment branch in tree of resources part? Is that like /api/ / / / would boil down to /api/cars/ford/fusion/ with cars, ford, and fusion each being a branch in the tree?

That's right, except that 'api' is probably a resource also. Your app provides a root resource with a __getitem__ method. Pyramid tries `context = root['api']`, then `context = context['cars']`, then `context = context['ford']`, and so on, until it uses up all the path segments or a __getitem__ raises KeyError. Then it looks up the view for the final context and calls it if all the conditions are met for the view configuration.

That's traversal in a nutshell. Resources can be database objects or any object with a __getitem__ method. Everything about traversal is customizable, but it's rare to need much customization.

Also, if your resources have __parent__ and __name__ attributes, you can ask Pyramid to generate the URL of any resource and view using `request.resource_url(resource, view_name)`, which is really handy for ensuring URLs don't break.

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#145
post #20

Earlier quoted context omitted.

Everything you wrote is true, however I think using another ORM in Django is asking for trouble, or at least it's missing a lot of the benefit of Django. The way models work with admin, forms, etc is to me what makes Django so efficient. Also, you don't get much by switching Django templates to Jinja.

> Also, you don't get much by switching Django templates to Jinja. Well, you gain a lot of performance - as much as 10x depending on the complexity of your template. Also, Jinja is a lot less crippled than Django Templates (for example, you can't call a function/method with parameters in Django Templates).

Thank you for pointing to the performance improvement, although I never found the templates to be the bottleneck (insert usual suspects here) it's good to know. Since I actually started my journey into python web development with flask+jinja2 and while I found the lack of parameters in Django templates disturbing at first, in practice it never really stopped me (custom template tags and filters...)

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#146
post #123

Earlier quoted context omitted.

They are probably not much better as frameworks than Rails or Phoenix but using Python allows you to import a lot of things from the Python ecosystem. (eg http://www.developintelligence.com/blog/python-ecosystem-201... )

Yeah. I asked because I really like Python's libraries in general, but I found Flask to be so-so, and I just recently worked on a large project in Django, which I hated. I was hoping there was some kind of up-and-coming framework in Python I didn't know about.

I'd probably blame the big project rather than the framework. Or maybe the use case was one for which Django is not particularly well-suited. I suggest playing around with the framework a bit until it clicks and then trying again in the future

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#147
post #61
post #20

Earlier quoted context omitted.

Everything you wrote is true, however I think using another ORM in Django is asking for trouble, or at least it's missing a lot of the benefit of Django. The way models work with admin, forms, etc is to me what makes Django so efficient. Also, you don't get much by switching Django templates to Jinja.

There are efforts in improving that in 3rd party libs such as django-sorcery [1] which attempts to add Django-like ORM experience but with SQLAlchemy and django-rest-witchcraft [2] which is adding DRF integration to SQLAlchemy models. Not everything Django ORM does is supported however a lot of useful functionality works as expected. For example nested resource updates in serializers in DRF works out of the box witho…

Thank you. Do you know of any effort to port GeoDjango functionality to other ORMs ? Or is this something Sorcery supports ?

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#148

This is a short list I have compiled a few months ago, FWIW: New kids on the block: - Starlette https://www.starlette.io - Vibora https://vibora.io - Xweb https://github.com/gaojiuli/xweb - Storm https://github.com/jiajunhuang/storm - Responder http://python-responder.org - Quart https://pgjones.gitlab.io/quart/ - Sanic https://sanic.readthedocs.io - Bocadillo https://bocadilloproject.github.io/ - Japronto https://gi…

I don't think Falcon is "old guard". It got stable just about 3 years ago.

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#149

Earlier quoted context omitted.

Don't know why this is downvoted - it's crystal clear advice for beginners - "just use Django".

Django brings a lot of concepts with it. It may be simpler to start teaching with Flask and build up from there until the need for something like Django becomes obvious.

Right. With Flask, I can simply get to the point where I'm rendering templates, styling with CSS, adding assets and populating template variables with data from simple (or complex) functions I've written.

You can take care of a lot with just that.

Re: A Beginner’s Introduction to Python Web Frameworks (2018)

#150

Earlier quoted context omitted.

Same can be said for any system, regardless of the language. Unless you’re able to create an artifact like a single executable or a Jar but you still need to supervise those and keep them running.

Say what you want to about PHP, but when it comes to deployment it’s hard to beat.

Technically the exact same setup can be had with Apache and mod_python. You don’t need WSGI to do python apps.
Post reply on HN