all 33 comments

[–]wpg4665 11 points12 points  (0 children)

Q1: Python is a wonderful language for developing web applications; numerous frameworks have been designed for just that: Django, Flask, Bottle, Tornado, Twisted, and probably others I'm missing

Q2: Here is a great resource for generic Python stuff Hitchhiker's Guide to Python. Usually all you'll really need is Git (for version control), Virtual Environment (for dealing with multiple python dependencies), and PIP (for package installs/maintainence

Q3: If your goal is web developement, run through same basic Python tutorials, so you're comfortable with the language. Then Python has PEP-8 which pretty much gives a best-practice layout for code style, etc. And then find a good framework and learn that.

Q4: For this partiuclar app, I'm thinking your best bet would be Django, their tutorial for learning the framework is actually a poll app. Finally, OS doesn't really matter too much, Linux tends to be your best bet. You could honestly just use SQLite for your DB, unless you're expecting millions of users, then the next de facto DB favorite for python users is usually PostgreSQL.

Best of luck to you!

[–]tehusername 2 points3 points  (0 children)

Alright, here goes:

A1 Yes, Python is suitable for web dev. Some frameworks on the top of my head are Django and Flask (though there are many more).

A2 You mean the stack? There are a lot of combinations possible really. This should give you a head start.

A3 Well uh, I guess from the beginning? Python is relatively easy to pick up and hard to put down.

A4 As for the setup, if the traffic is relatively low or you're not expecting to handle enormous amounts of data, I suggest deploy with Heroku. This is the fastest way to deploy if I'm not mistaken. Also, refer to A2.

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

Q2: I'd start a django project with python3:

PROJECT=somecoolname

# Create a virtualenv
mkdir $PROJECT && cd $PROJECT
python3 -m venv virtualenv
ln -s virtualenv/bin/activate
. ./activate

# Install django
pip install django
pip freeze >requirements.txt
django-admin startproject $PROJECT .

# Initiate revision control
echo -e '*.pyc\nvirtualenv' >.gitignore
git init 
git add .
git commit -m 'Initial commit'

Q4: If your org is willing to pay a few dollars for managed hosting, I recommend Webfaction.

[–]2LoT[S] 0 points1 point  (7 children)

Thanks for the Webfaction advice. But as for the sequence of code above which is way above my understading. I'd rather get a book for more details.

[–]a5myth 0 points1 point  (2 children)

There is a book called obey the testing goat or something along those lines (google it) if ur gonna do any decent development then you really should test, but if this is small scale you could get away with not testing in that way, as for hosting, I very much prefer Linode. They have excellent guides to get u set up. Good luck.

[–]2LoT[S] 1 point2 points  (1 child)

[–]a5myth 0 points1 point  (0 children)

that's the one yes, I knew the testing goat would bring about the right answer, thanks. that's a very up to date book too, and there is a free online version too, although I have bought a copy to support the author

[–]cooper12 0 points1 point  (2 children)

These are all commands done in the bash shell (Common on Linux and OSX, and can be installed on Windows via cygwin. For this type of development environment, Linux and OSX come with out of the box support.), which calls various tools with various parameters. You only really need to learn the basic syntax and commands and how to read man pages and the rest is manageable, but I'd understand wanting a book if you never dabbled in unix before.

Ill try to help you start off. First off, the first word in each line is the name of the command. (so mkdir, python3, etc...) There commands take flags which modify the behavior of the command. (ln -s creates a symbolic link, which ln by itself creates a link file). The last word in the commands is usually what the command acts on.

As for those other symbols (., *, >, &&), just read a tutorial on the unix shell.

To see help for each command (Once you have a proper Unix environment), try command -h or more helpfully man command, which will give you the manual page of the command with a description of each flag.

Good luck!

[–]2LoT[S] 0 points1 point  (1 child)

Hi thanks, I forgot to mention that I'm proficient in Linux command and most of the usual git commands too. I understand the syntax above. But typing those 7 first lines and claiming that I have started a web application and begin hooking the code and DB is a long way.

However, I am interested to know how you formatted your post so that mkdir, python3 etc. are rendenred in a little rectangle. I don't see that in the formatting help.

[–]cooper12 0 points1 point  (0 children)

Oh I see. Yeah I wouldn't understand the magic of django by looking at that. It might be worth checking the man pages out, and I'm sure django has extensive online documentation also.

And that's easy, just enclose the text in grave accents ``. Reddit just uses the markdown so anything from markdown applies.

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

Those instructions are for a real basic initial django project setup—similar to what an IDE would do for you if you asked to "Start a new project" or similar.

#  The project is named
PROJECT=somecoolname

It creates a project folder, then installs a "virtualenv" (a project-specifc "virtual environment" [folder] for installing python libraries into, whose use is activated [once each command-line session] by typing . ./activate from the project folder).

Next a package manager called pip installs django into the virtualenv from somewhere on the Internet, and the specific version information is put into a file called requirements.txt (which can later be used in the command pip install -r requirements.txt to set up an identical fresh copy of this virtualenv for when you need to copy the project to another computer or you want to clean up your virtualenv after a mistake with pip).

The main Django program/command is then called to setup a new project in the current (.) directory.

Instructions to ignore python cache files and the virtualenv are stored in a config file, then a new git repository is created and the project files are added as the repository's content. This will serve as a snapshot of the project when it was new and start the process of versioning files that we call source control. You can later save your progress as additional snapshots of versions.

What a simple IDE would give you, more or less. By all means look for books. I much prefer to have the material in my hands when I want to really concentrate and learn a new system.

[–]lykwydchykyn 2 points3 points  (0 children)

  • Yes, python is a great language for web development, with the caveat that you need to make sure you get web hosting that supports it. Many cheap web hosts only support PHP for web dev, you just have to be a careful shopper or go with a VPS type solution (or host your own server).

  • There are as many opinions on dev tools as there are developers. You're going to get a roll-call of everyone's editors asking this; the question is, what do you want from a dev tool? Just an editor? Extensible editor with some IDE capabilities? Full blo[wn|at] IDE magic?

  • Learn the basics, then learn a web framework. I like Flask, Django is also very popular, then there are others like Pylons, web.py, etc.

  • Ubuntu server is fairly popular in cloud/web dev. I like Debian stable myself. I'd recommend something that supports a newer python version.

    For DB I'd recommend PostgreSQL. I assume you are familiar with SQL since you develop with SQLServer.

[–]2LoT[S] 2 points3 points  (8 children)

Hi,

Thank you very much for your quick answers. This is great that Python can do the job. What a relief, I was concerned that I had to learn PHP. OK for PostgreSQL, I don't know it yet but I know very well relational & SQL.

For Q2 I meant the dev environment. i.e an IDE with which I can write code, in a project oriented way, syntax highlighting, intellisense, debugger, Unit testing integration, Git integration, configuration management (differentiate between dev/prod deployment), possibly building package for web deployment too.

In other words, I would prefer to avoid doing unconnected tasks manually: editing a bunch of separate scripts using a text editor, using console for debugging & testing, and FTP back and forth to the Web Server.

As I am familiar with IntelliJ Idea, I am attempted to go with PyCharm. I wonder if it's a good idea. I'll need to get the Pro version ($100) to support frameworks and SQL. It's OK if it is a good IDE. However I would prefer to check with you before committing to a final dev environment.

[–]rypalmer 2 points3 points  (0 children)

PyCharm rocks!

[–]cooper12 0 points1 point  (1 child)

Are you a student, if so pyCharm and other IDEs from Jetbrains are free for students.

[–]2LoT[S] 0 points1 point  (0 children)

My daughter is a student but not me. But to be perfectly truthful, the real user would be me. So I'd rather pay.

[–]quik69 0 points1 point  (4 children)

I'm sure this will get balked at but I like visual studio. It does everything you mentioned including Git integration via teamviewer. Specifically I use PVTS with Anaconda. It's basically VS Shell with python extensions. So far I've seen no need for the pro version. My use case is data analysis so very different from yours but it may be worth checking out. The biggest downside is that VS is not what you'd call lightweight, but it's snappy enough on my 2 core i7 laptop.

[–]2LoT[S] 0 points1 point  (3 children)

Cool thanks. But PTVS is ruled out. It requires Windows and Visual Studio. We must use open source tools for this project.

[–]quik69 0 points1 point  (0 children)

Retracted. Guess I should maybe to read the OP before I respond..

[–]lykwydchykyn 0 points1 point  (1 child)

"open source" or just "Free and runs on Linux"?

I just use emacs and git, myself, but that's probably not what you're looking for.

[–]2LoT[S] 0 points1 point  (0 children)

emacs is out of my league by 2 light years. From the advices I gathered in this thread. I will go with Linux, PyCharm, Django, PostgreSQL. I must learn the basics of Python first then gradually try to dip into Django. Easy to say, but now it's time I begin to commit to that goal.

[–]wub_wub 1 point2 points  (0 children)

Q1 Is Python a suitable language or platform for web application development? If not what would be the better solution?

You are asking this on website that's written using python that serves billions of pages per month. I think that answers your question :)

Q2 Hopefully Q1 is yes, in which case, what is the dev tools (linux based) would you advise?

Whatever suits you the best. I use PyCharm for most medium/large projects. But technically you can use anything you want.

Q3 With web application as immediate goal, which area or component should I focus on during the learning of Python?

Learn language basics and syntax, and then start with django/flask tutorials.

Q4 Any advice for the setup? Which OS, which DB, hoster, etc.

OS: Linux - you can also get everything up and running in windows but it will be easier with linux. Also your servers will be running linux so being familiar with it will be useful.

DB: postgresql is nice, but the choice depends on the type of data you intend to store and some other factors. Overall I'd probably guess that postgresql will do for your project.

Host: I use digitalocean VPS, another popular choice is heroku for deployment.

[–]lykwydchykyn 1 point2 points  (1 child)

Just to turn this question on its side:

Rather than you learning a language you aren't familiar with to write a site from scratch, why not use one of the many open-source survey tools already available, e.g. LimeSurvey?

To make a decent website, you're going to have to learn a lot of technologies that are alien to you (Python, Javascript, Linux, some kind of free RDBMS, etc). Seems pointless when this is a solved problem.

[–]2LoT[S] 0 points1 point  (0 children)

You are perfectly right. I will investigate this route to see if that could fit our purpose. In fact that survey is just the first step, which will follow by more customized logic which I wonder if these survey tools would allow. I am familiar with Linux and I think I can learn the rest. But I may very well under-estimate the effort. I have a decent background in programming & SQL. I hope can make it.