Pros and Cons of different approaches to web programming in Python

前端 未结 9 931
孤城傲影
孤城傲影 2021-02-01 17:40

I\'d like to do some server-side scripting using Python. But I\'m kind of lost with the number of ways to do that.

It starts with the do-it-yourself CGI approach and it

相关标签:
9条回答
  • 2021-02-01 18:17

    It's always worth doing something the hard way - once - as a learning exercise. Once you understand how it works, pick a framework that suits your application, and use that. You don't need to reinvent the wheel once you understand angular velocity. :-)

    It's also worth making sure that you have a fairly robust understanding of the programming language behind the framework before you jump in -- trying to learn both Django and Python at the same time (or Ruby and Rails, or X and Y), can lead to even more confusion. Write some code in the language first, then add the framework.

    We learn to develop, not by using tools, but by solving problems. Run into a few walls, climb over, and find some higher walls!

    0 讨论(0)
  • 2021-02-01 18:18

    If you've never done any CGI programming before I think it would be worth doing one project - perhaps just a sample play site just for yourself - using the DIY approach. You'll learn a lot more about how all the various parts work than you would by using a framework. This will help in you design and debug and so on all your future web applications however you write them.

    Personally I now use Django. The real benefit is very fast application deployment. The object relational mapping gets things moving fast and the template library is a joy to use. Also the admin interface gives you basic CRUD screens for all your objects so you don't need to write any of the "boring" stuff.

    The downside of using an ORM based solution is that if you do want to handcraft some SQL, say for performance reasons, it much harder than it would have been otherwise, although still very possible.

    0 讨论(0)
  • 2021-02-01 18:22

    If you want to go big, choose Django and you are set. But if you want just to learn, roll your own framework using already mentioned WebOb - this can be really fun and I am sure you'll learn much more (plus you can use components you like: template system, url dispatcher, database layer, sessions, et caetera).

    In last 2 years I built few large sites using Django and all I can say, Django will fill 80% of your needs in 20% of time. Remaining 20% of work will take 80% of the time, no matter which framework you'd use.

    0 讨论(0)
提交回复
热议问题