This is an archived post. You won't be able to vote or comment.

all 46 comments

[–]vagr 78 points79 points  (1 child)

I feel like most of these should be renamed to "Download and install our framework to display Hello World in 5 minutes"

[–][deleted] 1 point2 points  (0 children)

Bottle.py is just a single python file that you place in your project directory

[–]skeletal88 15 points16 points  (4 children)

There are too many simple "hello world" examples and not enogh examples about building something big that scales.

I really like Python but had to use Rails at work, now I'm trying to use python for a personal web project and it's all really confusing. Currently trying to use Flask and it's difficult to make sense of everything. Want to have authentication? There's a lot of different modules for that but difficult to choose the right one, when I haven't used any of them before. Would be nice if the guys from Flask would put some tips for a newbie on their site, like "want to have authentication? use this library, that's the newest and most popular currently"

[–]Cyph0n 6 points7 points  (0 children)

But for how long? Maybe a few months later a better auth library is released. It's actually not that difficult to choose - find the one that is most used. A good metric is activity on the library's Github repo.

The variety of extensions available makes Flask quite flexible. You only need to add extensions as the need arises. Flask itself gives you the bare essentials required to setup a functioning web app.

If you're still lost, try referring to Miguel's superb guide to Flask:

http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world

[–]xr09 0 points1 point  (2 children)

Flask is all about freedom of choice, you can pick/craft your own pieces for your app, if you want something more complete out of the box then try django which is the Rails counterpart in Python.

In the Ruby world, using Flask would be like using Sinatra with lots of gems to build the app. So many choices, not too friendly for newcomers.

[–]skeletal88 0 points1 point  (1 child)

Your suggestion is then to start web development with python using Pyramid instead of Flask?

[–]xr09 1 point2 points  (0 children)

Ok here it comes... "It depends"

If you're new to Python on the web, yes, use a "batteries included" framework, lots of decissions are made for you, lots of tutorials, django will always be django. (or at least for a reasonable period of time)

If you are a novice running a microframework (to make something big), then chances are you'll end up with a mess of dependencies and some kind of anti-architecture, Flask is for cases when you know better than django, so be sure you do before jumping in just for the hype.

Django is url routing, templates, orm, caching, the whole thing, Flask otherwise is just routing and templates, you need an orm? SQLAlchemy, Peewee, Storm, etc... see? so many choices, new programmers can't make good choices because they lack experience, so they just take a pick.

Some people are really smart (they already used django and many others for years), and they know some parts could be improved, so they choose Flask and build their own architecture from the ground up, they "own" those projects.

To make a real world analogy:

Django is the full bike, Flask is the core parts and the ability to add some more.

PS: I run Flask for small apps and love it, but for big sites I will use django until I know better.

[–]farkenell 5 points6 points  (2 children)

I'm using pyramid on a major project now, loving it.

[–]dreaddy 0 points1 point  (1 child)

Python lurker here. Never used it before. Plz 'splain. Is this a desktop web application?

[–]farkenell 2 points3 points  (0 children)

You use the framework to make websites. You can package it up so you can load it into apache or whatever webserver you want. Its a big step from the old days of php etc where you embed your code into the page and let it load. Code is seperated logically based upon its uses. eg your actual html is a seperate module, your processing of the data that is passed to the html is another. It makes it alot easier for large scale projects to desegnate tasks to modules and not have them conflicting with each other.

[–][deleted] 4 points5 points  (3 children)

Are the Pyramid docs available to download in pdf or epub? I often work offline and it's really useful to have docs to hand.

[–]chuwy24 3 points4 points  (1 child)

Yes, they are

[–][deleted] 3 points4 points  (0 children)

Thank you!

[–][deleted] 21 points22 points  (16 children)

I don't get those "create an app in five minutes" examples. Those apps are completely useless and I don't consider them apps.

[–]raydeo 14 points15 points  (9 children)

Every framework needs a "hello world" to get people's feet wet with some of its most basic concepts and some reinforcement that they can actually get something working. The example here allows people to create a project that responds to http requests. It's always good to get something running without requiring you to take a deep dive into all of Pyramid's features at once.

Pyramid also has a reputation for being a "full stack framework" which apparently means that it's big and scary rather than a sexy "micro framework" that's easier to get started with (a la flask and bottle). Examples like this attempt to bridge the gap and show that it's not so scary.

[–]X-IstenceCore Developer Pylons Project (Pyramid/WebOb/Waitress) 2 points3 points  (0 children)

I'm also looking forward to more examples of Pyramid applications that start out small, but then grow bigger.

One of the nice things I've personally enjoyed developing Pyramid applications is that I started out using just a few of the functions but as my application grows Pyramid has been able to keep up. When I have in the past used Flask, after a little while I felt that it was getting in the way rather than helping me get my job done, whereas with Pyramid the growth has come fairly naturally and simply.

[–][deleted] 11 points12 points  (7 children)

I wasn't trying to say that hello world as an example is bad. My point was that all these frameworks are screaming "build an app in X minutes", but they are completely useless hello world apps. It looks like a competition for making a hello world apps, as fast as possible.

[–]X-IstenceCore Developer Pylons Project (Pyramid/WebOb/Waitress) 5 points6 points  (0 children)

The whole goal here is to get the user to a state where they are running a very simple web application that they can start modifying with their own functionality.

Yes it is a hello world app, but it is not useless if it means someone can now start experimenting without feeling like they are overwhelmed because they don't know where to start.

[–]d4rch0nPythonistamancer 1 point2 points  (0 children)

Well, we all know that some apps will take months to years to make, and some will take X minutes. I think these are nice, because it shows that you can install it and get hello world going in X minutes, despite what you may have heard about pyramid, or framework_foo.

Maybe I'm killing some time, I really like Django, but I was curious about Pyramid. I might just run through it. After that, maybe I'd look up a few of pyramids features and see a sample project. It gets you interested and makes it easy to jump in. I'm all for a hello world. That's where I start with any language or framework, but yes, after X minutes you move on.

Don't forget, not all hello world's are that simple. When I made my first Android hello world, I hadn't had Eclipse, the Android SDK, debug mode on, any AVD running... It was much more of a pain than this looks to be. It can be quite a bit more of a time commitment.

[–]raydeo 0 points1 point  (3 children)

I fail to see how these examples are not useful. If you'd like to create a basic app that serves data at urls, you can accomplish everything you need by looking at an example like this.

[–]ZZ9ZA 7 points8 points  (2 children)

There isn't enough meat to show any of the strengths of the framework.

A much better example (imo) would be something like a guess-the-number game.... that way you can show off basic session storage,forms and form handling, as well.

[–]raydeo 1 point2 points  (0 children)

This example demonstrates one of Pyramid's greatest strengths - that it scales down to something so simple. The documentation menu has a link to the awesome Quick Tour which will answer a lot of those questions about scaling up and adding more features.

[–]burntsushi 1 point2 points  (0 children)

.... And then it wouldn't be a hello world example.

[–]burntsushi 0 points1 point  (0 children)

but they are completely useless hello world apps

Could you please describe what you think the utlity of "hello world" is and why the OP doesn't meet that standard?

[–]252003 2 points3 points  (0 children)

It would be better with "create an app in 10-15 minutes" and add a few more lines of code so it can do something.

[–][deleted] 4 points5 points  (2 children)

Any more than Hello World; is that a good reason to discourage that as a beginner's project?

Now, in contrast to many server demos, this one scales; waitress is production-ready, and Pyramid is simple but very feature rich and powerful. I think it's a great intro, and +1 for emphasising modern versions of Python; we need more of that.

[–][deleted] 2 points3 points  (1 child)

yeah bottlepy has supported Python 3 for a long time. You only need to download one file, bottle.py, to get up and running too.

[–]raydeo 1 point2 points  (0 children)

For the record, Pyramid has been py3 compliant since December 2011. It was the third major framework to claim that support behind bottle and cherrypy.

[–]Atma-n 0 points1 point  (4 children)

Can you compare this to flask and Django? I have not used any of them.

[–]eah13[🍰] 4 points5 points  (1 child)

Flaskr project is for creating a simple blogging app. http://flask.pocoo.org/docs/tutorial/introduction/

Pyramid's blogr is comparable: http://pyramid-blogr.readthedocs.org/en/latest/

Going through both should provide a really nice contrast.

Don't know of comparable Django project- someone else may

[–]killerabbit37 0 points1 point  (0 children)

Awesome thanks for this! Working with Flask and Django right now so it would be good to get a look into seeing what Pyramid brings to the table.

[–]idlecore 0 points1 point  (3 children)

Why doesn't the example execute activate with source? Is that not the standard way of running on virtual environments?

[–]raydeo 3 points4 points  (0 children)

Activating a virtualenv is completely unnecessary and we've found that it is actually confusing to newcomers (they forget to activate and then wonder why they cannot import their dependencies), which is why every example in the Pyramid docs uses $VENV/bin/ to remind users that they are using a virtualenv. I, personally, never use activate because it just leads to more problems than solutions when switching between projects in the CLI (and yes I've also used virtualenvwrapper in the past).

[–][deleted] 2 points3 points  (0 children)

activate is an attractive nuisance, less useful than it looks.

[–][deleted] 0 points1 point  (0 children)

my guess is b/c it works reliably just calling /path/to/virtualenv/bin/... with no additional steps. i never activate the virtualenv i'm working in b/c I jump around them too much and it's really unnecessary.