As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am currently learning PHP and want to learn about OOP.
I know Python is a well-organized and is all OOP, so would learning Python be a wise choose to learn OOP?
The thing is I am more towards web development then just general programming, and I know Python is just a general purpose language, but there is Django.
So how should I go about learning Python if I am lending towards web development?
Is there any good books/websites that help me learn Python for web development?
Is there any free webhosting companies that allow Python? I never used Python before, only PHP, and not sure how it works? Is there like a "xampp" for python?
I would pick up a good O'Reilly book on Python and build a strong understanding of the fundamentals before delving into more web specific ventures. Once you've got the essentials then I'd branch out to things like Django.
Here's a good starting page:
O'Reilly - Python
And here's a good tutorial if you'd rather do your research on the web:
Python Tutorial
I learned Python reading the book Learning Python. I read almost the whole thing on a plane trip, and when I got home I was able to start building applications immediately. There are newer versions out since I read it (and it's longer), but I found it very easy to follow.
As mentioned by others, Django is definitely the place to start for Web development.
Work through the examples on www.pythonchallenge.com. Refer to the language documentation when you get stuck.
As long as you stay within their quota Google Apps Engine provides free hosting for Python.
Django is a great framework when you want to do webdevelopment with Python. Django also has great documention with http://www.djangobook.com/ and the official Django website.
If you want to learn about Object Oriented Programming in general, you may want to look at the answers to this question, although many of the books are higher level (and some are aimed at Java/C# like languages instead of Python-like languages).
Here's some answers to your questions:
Python is an excellent language for beginners looking to learn OO design/programming.
As far as books and websites, the best python book I've read is available free online Mark Pilgrim's Dive into Python.
For web programming there are many many options. You mention Django which is the most popular although I like Turbogears, Cherrypy and web.py. All of these have their own webserver built-in (Based on paste or cherrypy)
For hosting, it's usually based on fastcgi or Apache's mod_python.
I've heard really good reports of webfaction for python based hosting.
Hope this helps, but if you are learning php why not go for Apress's PHP Objects, Patterns, and Practice that's a good book.
If it is your basics in OOPS that you wish to strengthen, Java is a good option(provided you know c++ or any other non-web-based language which supports OOPS). However, if you are looking towards web-development, Python should be your best option.
Yes, Python is a good option
Yes, Django is a very good web application framework(and they have awesome documentation and tutorials put up at their site)
To learn Python I definitely recommend reading "The Python Cookbook" cover-to-cover. Its fun, and covers some very important concepts. However, there really is no substitute for the standard python documentation. Its well written, but it might take a while through a major portion of it. Using it as just reference material is also a fine idea.
Well I have seen domains which allow Django to be hosted; also you should try out the GAE(google app engine) once you are comfortable with django. Its a great place to host your apps.
You could learn using books, but nothing beats practical hands-on approach - so make sure you have Python installed in a computer to help you learn. If you decide to buy a Python book, I strongly suggest you DO NOT buy a copy of Vernon Ceder's Python Book, it has very bad reviews. I bought a copy and was also disappointed.
If you'd like to join a mailing list, we have a good community at Python Tutor. Sign up and post your questions there as well.
Good luck
Get ipython. Use it as your shell. This means move, copy, view, change, edit files from ipython. Day to day shell stuff anywhere has enough little problems that one ordinarily solves by piping, but are just as easily solvable by python. The real bonus is that your eye for syntax and simple solutions will develop quickly.
Need to find files? use os.walk,
Running grep? try to 'open' the file instead, try some regex while you are there. Those uses of the language will serve you in any type of python programming.
( Good news, PHP and python use the same underlying regex lib PCRE, so although there are some additions, it'll be familiar to you, )
The nice thing about having this in the language , which is not really the case in PHP or Perl, is that you can just mess around with functions, not full programs.
Why ipython and not the standard REPL or bpython? Easier to use as a shell out of the box. That's all.
I recently learnt Python and had very little programming experience before. I found that doing a little bit of Python first then diving into Django worked for me. USing Django, looking through its reference material and Googling individual problems when I needed the help was really good.
Django has a built in Development server for you to use a bit like xampp, however, to make things like installing Django, installing Python, installing plugins etc a lot easier, use a unix based OS. I am developing on Mac OS and I have had no problems. Most Linux distributions will be the same. I wouldn't want to try Django development on Windows, there are just too many hacks you need to do to get it working, plus, it is more difficult for when you then publish the site (on a unix server).
Learn some Python, there are some good books suggested here, but don't get too deeply stuck into it if your focus will be Django. Go and do the official Django tutorial and then Google around for one or two more.
I use a book called 'The Definitive Guide to Django'. It is great for learning Django in the first place, but after the first few chapters, I stopped following it and started my own projects instead. Now it is a really good reference book to have.
It takes a while, but its worth it. I started working at a company as a Django developer recently and it is great.
Good Luck!
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have been studying Python at work for a week now and it seems very interesting, I started using it in order to create Extra Search functions for Splunk.
My Question is, what else can you do with it?, is it only a Script Language?, if so what type of scripts can I create and use?
To what extent should I learn Python in order to begin writing usable scripts?
I can write a Shell Korn script to Query a MySql Database, Can I do the same with Python?
You can pretty much do anything with Python that you can do with ksh, only easier (shells have a lot of stuff built in but many scripts will "reach out" to helpers like grep, sed awk, and so forth, to do grunt work).
Python also comes with an insanely large library (just like Java and C#) and plenty of add-on modules, both of which also include database stuff.
You don't have to learn Python to be able to script successfully, there's a large array of solutions for this. But Python is a useful weapon to have in your arsenal.
Bottom, it's quite able to handle a huge number of tasks, including the specific one you mentioned.
Aloha!
The obnoxious answer is that Python like other languages are turing complete and you can write program in it. But that probably doesn't answer your question. ;-)
First however, a tip: Stop think in terms of scripting vs real programming languages. Python, just like Java, Perl, Ruby, LISP, Scala, Lua, Cloujure are just as much real programming languages as C, C++, Fortran etc. The main difference is what they are running on. C for example can run on "bare metal", that is basically be translated to sequences of instructions that can be executed by the native/real CPU. Python, Java etc relies on a virtual machine to execute their instructions. The VM is then run by the real CPU.
The VM costs some performance, but add things like portability, dynamic behaviour (introspection, duck typing etc) that make the language and systems written in it very efficent in ways it is harder to do (but not impossible - remember Turing completeness) in for example C.
With that in min (Python is a real programming language) you might not be surprised to learn that Python can be and is used for things like:
Network servers and network applications. Look at the great Twisted networking framework and look and beautiful applications like Trac.
Large scale, professional distributed version control. Mercurial (Hg) is written entirely in Python and is able to handle huge, active projects with developers on a global level.
Compilers, languages and virtual machines. There is actually a virtual machine able to run Python written in Python(!). The machine called Pypy use some of the dynamic functionality of the language to enhance the performance.
Pypy is really a groovy concept - having the machine you are running your code in a language that can be modified at runtime - basically rebuilding the "hardware" from your application to enhance the machine to at the whim of the application. (And yes, I'm aware that all LISP guys yawn at this point - nothing new but still very, very groovy)
There you have it, some IMHO good, everything but simplistic, non-professional applications. Now start reading up on Python.org about the advanced features of the language and amazing functionality readily available in the standard lib. Your programming life will thank you for it.
Good luck!
To answer your questions in order:
Everything.
No.
Any.
As much as possible.
Yes.
Start here
I am a Python/web programmer.
Now, I would like to transition to building applications for the Mac.
Please tell me--what do I have to learn to get started?
What books would you recommend?
Assuming that you included the "python" tag after considering that it will be interpreted as applying to the question and not the questioner, you must be interested in writing Python applications for the Mac, right? After all, you didn't include "web" as one of the tags too.
If that's true, I'm not sure what more you need to know already, other than perhaps picking a GUI framework, if you want to write GUI applications.
I use wxPython quite successfully for applications which run on OS X (and Windows). Very few Mac-specific issues have cropped up to cause trouble, primarily because both Python and wxPython are remarkably cross-platform. The few that have come up are by and large documented and have known workarounds, or the resolution is fairly simple to find.
I've needed no books on the subject, and really know very little about Macs. It really hasn't been a problem so far.
The programming language of choice for building OS X gui applications is Objective-C with Cocoa, I would recommend that you check out some books on that. There are python bindings for Cocoa but they are not optimal.
You should check out previous questions looking for books on Obj-C and Cocoa.
What are some applications for Python that relative amateur programmers can get into?
For example, Ruby has Rails for building web applications. What are some cool applications of Python?
Thanks.
Google App Engine has excellent support for developing -- and especially for deploying -- web applications in Python (with several possible frameworks, of which Django may be the most suitable one for "relative amateurs"). Apart from web apps, Blender lets you use Python for 3D graphics, Poser for apps involving moving human-like figures, SPSS for statistics, scipy and many other tools included in Enthought's distribution support Python use in scientific programming and advanced visualization, etc, etc -- the sky's the limit.
"cool" is a state of mind. Hence cool applications depends on your definition of cool. A Ant colony simulation is cool, if you want to implement the theory.
Python, with its own and 3rd party libraries (batteries) has been applied in possibly all domains of day to day programming. My advise is, decide on the cool app you want to write and then see, what Python has to offer in that domain. If you are sufficiently satisfied, you can start coding. Good Luck!
You can build web applications in Python. See the Django framework.
Besides that, here's a nice list.
Not particularly relevant, but interesting, is the fact that NASA uses Python.
I wasn't a programming amateur at the time, but using pygame was my first intro to Python.
Python is a general purpose programming language much like Ruby. It can be used for systems programming, embedded programming, desktop programming, and web programming. In short, it has about as much potential for "cool" projects as any other general purpose language.
One of the first bits of Python programming I ever did was to hack on the nicotine client for the Soulseek peer-to-peer network to add a '/g [query]' chat command to open the default browser and search Google.
Probably not the most general purpose example, but I learned Python when AutoDesk Maya adopted it as a secondary programming language to complement MEL (Maya Expression Language). By comparison, it was a god-sent.
I like:
Django, for web development
PyQt4 for GUI programming
pygame for games, input management etc
PIL - python imaging library, it's not huge application, but really helpful and library imo
also, Blender is an application scriptable in Python, so if you'd be into some 3D graphics, here you got it.
If you're making applications for windows and want to ship them easily, you can also look at stuff like py2exe.
I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course and not get into University. So this is quite important to me.
I want to use Python to develop a Cocoa app. I know that I need PyObjc, however all details on the net seem to assume it is pre-installed. Apparently this is the case with Leopard and Snow Leopard but I don't seem to have it on Snow Leopard and never noticed it on Leopard. Also, I have tried installing the latest beta of PyObjc by following the instructions on the Sourceforge page, but with no luck.
I would really appreciate it if anyone could shed some light on what needs to be installed, how, and links to any resources or tutorials that could help me.
Thanks in advance for the help!
Update: I see that this is a popular question, I just got the 'Notable Question' badge for it so I thought I would update anyone coming to this page on what I did after getting the answers.
Unfortunately, I wasn't able to use Python to create a Mac application. This was rather disappointing at the time, but probably a good thing. I made a Windows app in C# for my project, it was a tool for creating and running Assembly apps in a simulated environment. My course teacher has now started to use my tool to teach the course instead of his own! I got a very high score on the computing project (over 90%) and this contributed to me getting an A* in my computing A-Level (the highest grade available) and I consequently got in to Southampton University to study Computer Science.
This summer, I decided to make an iPad app (soon to be released) and I am glad to say that I know think I could make a Mac OS application in Objective-C as I feel I have learnt enough. I am glad that I took the time to learn it, it is a great language and really useful with iOS becoming so popular.
Sorry for all the boasting, but I am really happy about it. What I really want to say is, if you are coming to this page hoping to use PyObjc to create Mac apps easily, don't bother. It takes some time and some effort, but once you have learnt Objective-C, it is really satisfying to create apps with it. Good Luck!
Allow me to echo what has already been said. I too am a student who just started a Cocoa development project, and at the beginning I thought "Well, I already know Python, I'll just use PyObjC and save myself from having to learn Objective-C, which looks beyond my grasp." I learned quickly that it can't be done. You can develop for OS X without learning Objective-C, but not without learning the Cocoa libraries, which constitute 99% of what you need to learn to write a Cocoa app in Objective-C. Objective-C itself isn't that hard; it's the Cocoa libraries that you need to invest in learning.
PyObjC basically uses Cocoa libraries and Python syntax. I gave up with it quickly and decided that if I was going to have to learn Cocoa, I may as well use Objective-C.
If you're looking to learn, Aaron Hillegass's book is a good place to start. Good luck!
You mean like Checkout? :-) I only mention it because Checkout is gorgeous and written with PyObjC...
Your concerns are valid, although probably not as much of a potential showstopper as you'd think. Using PyObjC still requires you to learn some Objective-C, and definitely requires you to understand at least some of the Cocoa frameworks, since you need to call into the Cocoa frameworks whenever you need to do some sort of Cocoa-specific task.
I recommend you read and consider the SO question "Why is the PyObjC documentation so bad?" and "PyObjc vs RubyCocoa for Mac development: Which is more mature?" before you completely convince yourself that "just PyObjC" will make things much easier. I refuse to disparage PyObjC because it is quite powerful and incredibly useful, but realize that nothing is a silver bullet, and no language or technology is best for all problems.
The Objective-C language is simple and pretty straightforward. The Cocoa frameworks generally dominate the learning curve for new Cocoa programmers. Plus, you have StackOverflow and lots of other resources to help answer your questions. (Judging by the activity of the "pyobjc" tag, you also stand a better chance of getting good Objective-C help on SO.)
And as one of the Checkout developers I'll weigh in too (hi Quinn!). From what we've seen PyObjC runs fairly well on Snow Leopard. We've built one of the latest SVN revisions 2.2b with some customizations on Leopard and just moved over the site-packages folder.
Theoretically you should be able to use the built in Python/PyObjC (just do import objc, Foundation, AppKit) but as we ship/work with custom versions of both Python and PyObjC I'm not sure what the status exactly is. The mailing list doesn't mention a lot of people having issues (just a few) so that could be a good sign.
Good luck with the project, and if you have specific POS questions shoot me an email ;-)
I hardly use PyObjC myself, but I believe you need to run the Xcode installer on the Snow Leopard DVD in order to use PyObjC.
Also, as Quinn said, you will need to understand at least some Objective-C in order to use a Cocoa bridge like PyObjC without tearing your hair out. It just doesn't insulate you that completely.
I'm going to agree with Quinn here. Even if you're already proficient in Python, learning how to interface Python and Cocoa is not going to be any easier than learning Cocoa with Objective-C.
Objective-C is a simple, clean language that is quite easy to grok. Building the GUI and hooking it up to the back-end will be harder than learning the Objective-C to write the back-end, and building the GUI and hooking it up isn't that hard.
Follow the Cocoa app tutorial (you should be able to get through it in a day, or maybe a weekend if you go slow) and you'll be well on your way.
I'm a long time python developer who's been doing iPhone apps for awhile now (and only using my python knowledge to package up build files for the apps in run scripts), then who started making some PyObjC apps.
I'd have to say, PyObjC is pretty much STILL having to learn objective C (which I already know via iPhone dev), however you get several pretty cool benefits if you use it instead
Easy use of python libraries you know (faster for you)
Option to drop it and go to wxPython if styimied by Cocoa
Somewhat faster development time (you're writing less code, and the translation between the two languages is pretty darn easy to get used to).
Additionally, interface builder is a little tricky to get used to comparatively speaking, but if you're a python dev, it's not like you're exactly used to a functional gui builder anyhow :oP
The background
I'm building a fair-sized web application with a friend in my own time, and we've decided to go with the Django framework on Python. Django provides us with a lot of features we're going to need, so please don't suggest alternative frameworks.
The only decision I'm having trouble with, is whether we use Python or Jython to develop our application. Now I'm pretty familiar with Java and could possibly benefit from the libraries within the JDK. I know minimal Python, but am using this project as an opportunity to learn a new language - so the majority of work will be written in Python.
The attractiveness of Jython is of course the JVM. The number of python/django enabled web-hosts is extremely minimal - whereas I'm assuming I could drop a jython/django application on a huge variety of hosts. This isn't a massive design decision, but still one I think needs to be decided. I'd really prefer jython over python for the jvm accessibility alone.
Questions
Does Jython have many limitations compared to regular python? Will running django on jython cause problems? How quick is the Jython team to release updates alongside Python? Will Django work as advertised on Jython (with very minimal pre-configuration)?
Decision
Thanks for the helpful comments. What I think I'm going to do is develop in Jython for the JVM support - but to try to only use Python code/libraries. Portability isn't a major concern so if I need a library in the JDK (not readily available in python), I'll use it. As long as Django is fully supported, I'm happy.
Django does work on Jython, although you'll need to use the development release of Jython, since technically Jython 2.5 is still in beta. However, Django 1.0 and up should work unmodified.
So as to whether you should use the regular Python implementation or Jython, I'd say it's a matter of whether you prefer having all the Java libraries available or all of the Python libraries. At this point you can expect almost everything in the Python standard library to work with Jython, but there are still plenty of third-party packages which will not work, especially C extension modules. I'd personally recommend going with regular Python, but if you've got a ton of JVM experience and want to stick with what you know, then I can respect that.
As for finding Python hosting, this page might be helpful.
I'd say that if you like Django, you'll also like Python. Don't make the (far too common) mistake of mixing past language's experience while you learn a new one. Only after mastering Python, you'll have the experience to judge if a hybrid language is better than either one.
It's true that very few cheap hostings offer Django preinstalled; but it's quite probable that that will change, given that it's the most similar environment to Google's app engine. (and most GAE projects can be made to run on Django)
I have recently started working on an open source desktop project in my spare time. So this may not apply. I came to the same the question. I decided that I should write as much of the code as possible in python (and Django) and target all the platforms CPython, Jython, and IronPython.
Then, I decided that I would write plugins that would interface with libraries on different implementations (for example, different GUI libraries).
Why? I decided early on that longevity of my code may depend on targeting not only CPython but also virtual machines. For today's purposes CPython is the way to go because of speed, but who knows about tomorrow. If you code is flexible enough, you may not have to decide on targeting one.
The downside to this approach is that you will have more code to create and maintain.
Django is supposed to be jython-compatible sinc version 1.0.
This tutorial is a bit outdated, but from there you can see there are no special issues.