Is there any article/paper on what features the Python language has to offer? Why should one go with Python instead of any other language? What are the strong and the weak points of Python?
Why Python
and
Why Python
so
Choose Python (import this)
Probably the prime reason I use Python is because it's very good at self-documenting. There are lots of other reasons too, but probably the best way to find out is to do something with it. Find a project and see what it takes to do it in Python. It may not be great Python code, but you'll learn more about how it suits you than from an essay. I know the first time I looked at Python, I didn't give it much chance (just looked like Matlab as far as I was concerned), but after using it for a couple of years, I have to say I have no regrets.
Paul Prescod Why I Promote Python has many good points why python is a good choice.
Why Python? Because all the cool kids are doing it.
Disclaimer: I just noticed "popularity-contest" running on my machine so I investigated. Although quite useful for QA and planning, one can't actually derive any meaning from that graph which could at least as well be explained by the rise of Ubuntu installations and their Python based administrative tools. This link is for amusement purposes only, void in Idaho and Nebraska.
Related
there is a year old, similar question - but in case there have been changes afoot:
i'm an intermediate c++ programmer just starting out on python, post some online tuts etc i can do some basic pythoneering, but was wondering if there are good places i can look online for simple(ish) --pref console based-- code that i can learn from, ideally with some sort of commentary.
anything come to mind?
thanks
The standard library is an excellent place to the start. It's maintained by the core python team and is of high quality with a lot of interesting idioms. I'd recommend the newer modules since they don't have much backward compatibility cruft and are more representative of the language as it is now. The older ones were written for earlier versions of Python and have some restrictions when it comes to API changes etc.
The list of modules in the standard library is described at http://docs.python.org/library/. You can go through it and decide which one you want to look at (area of interest etc.).
Their sources are viewable at the mercurial repo here http://hg.python.org/cpython/file/d7e85ddb1336/Lib (as of today). These are for the mainline 2.6 release. You can also checkout the repo and browse it on your local machine.
You can also start up your interpreter, import a module (say os) and do a print os.__file__ to see where the source file is if you want to look at the code in your local editor.
ActiveState Recipes is a good source for all kinds of Python scripts. But if you want to learn the basics of Python, you might just want to look at the standard library that ships with Python ("lib" directory").
i came across This The other day, Probably you can learn some python basics and have a laugh too!
Anyways, look at the libs as they said above, they are very useful
If you enjoy riddles:
www.pythonchallenge.com
If you're an intermediate C++ programmer, you're already equipped to handle to programming concepts. I like it because it gives me a reason to learn each part of the language, without being mundane 'Hello World' tasks.
However, some of the riddles are pretty tough and/or unrelated to programming. Either way, doing the first few will probably be enough to get your confidence up with Python syntax.
I'm a newbie to programming and I've decided to start with Python. Just curious though, is it enough/recommended to learn Python from online tutorials or from books? I want to go further than simple "Hello World!" programs. I'm not sure if books will actually teach you how to make more advanced programs.
One example is Exif-py. How do you even start programming a program like this? Do you just sit down and start writing the code, or do you have to search for APIs or anything? I went through the code briefly and it all looked alien to me.
I'm not really sure how to express my questions into words, so do check back because I'll edit my question if the right words come to me.
Well, I learnt all my Python from online sources (not just tutorials, but reference documentation, blog posts and other texts). It's certainly possible, although some people prefer the "guided" way a book teaches you, particularly people new to programming (at that point I had already been programming for years).
To create a program such as Exif.py, you would first have to know what you must do in broad terms BEFORE starting to program. You would study the EXIF format, then figure out how that is put into the image files, then you would have to formulate that in terms of the language you're using (in this case, Python). This usually requires that you're already familiar with it, otherwise it'll be a fairly slow process.
I'd suggest starting with simpler programs to begin with, or maybe follow a book such as Dive Into Python (free online), seeing as you're new to programming, and need to not only learn the language, but to think like a programmer.
The tutorials are there to teach you the language syntax and the standard library, not really on how to solve a particular programming problem. Think of what you learn there as your toolbox.
I think I understand what you are saying. You want to break above and beyond the simple applications and write your own stuff, right? Well, first you need to figure out what it is you want to make. Then comes the hard part; how are you going to make it? I'd suggest starting by trying to break it down into a number of small simple problems instead of tackling it as one large problem.
If you are trying to find examples of larger projects, I'd suggest looking at the Python Cheeseshop (package index) and download a few packages you've heard of to see how they did it. Also, people often post handy pieces of code on their personal blogs and that shows up on PlanetPython.
If stuff like recursion, modules, classes, iteration, exceptions, dictionaries, are indeed new to you, I suggest How to Think Like a Computer Scientist in Python (lovingly abbreviated as ThinkCSPy in the community ;-).
It is a bit outdated - for best results, use Python 2.6 or lower, but then again 3.0 is not that different.
EDIT: If ThinkCSPy has little to teach you, try Dive Into Python. It's advanced and pretty "real-world", but step-by-step.
If by 'newbie to programming' you mean that you just started it last week or something along the lines, then maybe you might want to give the MIT OpenCourseWare Introduction to Computer Science videos (and homework!) a bit of your time.
The opencourse covers the syntax of the Python language, some helpful hints and general do's and don'ts that apply to any programming paradigm.
Though, if by 'newbie to programming', that you already know the basic concepts you need to start writing basic programs (like adding, subtracting, multiplying, logical operations, functions etc).
If so, Project Euler is particularly good for exercising that cranial muscle in problem solving via programming, though most of the problems on the site require you at also have knowledge of mathematics (and if you don't, at least know how to google).
Just remember, if you get stuck on anything don't get put down! It's all part of learning! If you're really stuck, search SO!
There are a few very good online resources:
The Python Tutorial.
Dive Into Python. Python from novice to pro.
Code Like a Pythonista: Idiomatic Python
Another list of resources: Essential Python Reading List.
Most Python books I've seen so far are "not that good" - but that depends
on your background / prior knowledge about Python and programming.
You study the EXIF format, study the GIF/JPEG format, open the binary file, scan it and get the data out.
When digging into legacy Python code and writing Python code myself, I often use pylint. I'm also using Clone Digger. I've recently started to use rope, which is a library for automated refactoring.
But I'm looking for something else than rope. I would prefer a tool that just makes suggestions about possible refactorings: names the refactoring, optionally provides a short description of it (great for learning purposes), highlights the code section and lets me do the refactoring myself. Is there such a tool?
Check out bicycle repair man http://bicyclerepair.sourceforge.net/
What is Bicycle Repair Man?
The Bicycle Repair Man project is an attempt to create refactoring browser functionality for python. It is packaged as a library that can be added to IDEs and editors to provide refactoring capabilities. Bindings for Emacs and Vi are included with the package.
Never used it myself, but have read about it. Sounds like what you are looking for.
You might like Pythoscope, an automatic Python unit test generator, which is supposed to help you bootstrap a unit test suite by dynamically executing code.
Also, have you checked out the rope.contrib.codeassist module? It is supposed to automatically propose and perform refactorings of your source code for you.
I don't if that type of tool exists in any specific language, although the concept was mentioned in Martin Fowler's refactoring book (web reference).
The best tool I know of that currently exists is cyclomatic complexity. This article implements a cyclomatic complexity counter for python.
The other easy metric to target is method/function length, number of attributes of objects/classes and number of parameters to functions, if I recall, pylint already counted those.
Oh Forget about your tool, instead use TDD and a good book like refactoring to design patterns by Kerievsky. The problem is that refactoring is a way to improve your code and design, but only You can know what you want to achieve, no refactoring tool can do it for you.
My point is that best way to learn refactoring is to study examples, not to follow some stupid/simple tools, because they wont teach you any sophisticated refactoring nor they will tell you if you have refactoring that compose well with you code.
PS Read Fowler "Refactoring" and Kerievsky "Refactoring to design Patterns" those books are must read when learning refactoring. And they mention simple way to checking if refactoring is needed (smells).
Also consider TDD as good way to ensure that your refs are safe and do not break your code.
Beck "Test-Driven Development by example" is a good book to start with.
And Python have PyUnit for TDD.
NetBeans has an early access version that supports Python, and it is rather nice. It has some basic refactoring tools that I found the be useful. As an added bonus it works on Windows, Linux, Mac OS X and Solaris.
Check it out at:
http://www.netbeans.org/features/python/
I want something simple in order to experiment/hack. I've created a lot interpreters/compilers for c and I just want something simple. A basic BASIC :D
If you don't know any (I've done my google search...), yacc/bison is the only way?
Thx
PLY is a great parser-creation library for Python. It has a simple BASIC interpreter as one of its example scripts. You could start there.
None of these listed in TheFreeCountry are acceptable? None of them are in Python, but I should think that starting from XBLite might be more helpful than starting from Yacc/Bison/PLY.
Also, Vb2py might be a better starting position than PLY.
If you must go the PLY route, however, consider the MOLE Basic grammar as a starting point rather than trying to roll your own from scratch.
I also don't know a basic interpreter under ruby, but given enough time and interest ruby easily "supports" writing an interpreter for any language you like: Agile DSL Development
in Ruby . I must admit that this approach comes with some investment of time. :(
At the end of the presentation are some links to further readings regarding DSLs.
You may wish to also examine the Parrot virtual machine which, according to wikipedia today, has some BASIC support.
a miniBasic in ruby is available here. Rockit seems WAY more fun that racc.
There is pybasic (python basic), rockit-minibasic (rubybasic).
To make these able to use the gui, then one has to develop extensions with kivy and shoes gui toolkits for pybasic and rockit-minibasic respectively and similarly prima gui for perlbasic if ever exists.
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand oop), but Python is so awesome that I would like to help the community. What's the best way for a beginner to contribute?
Add to the docs. it is downright crappy
Help out other users on the dev and user mailing lists.
TEST PYTHON. bugs in programming languages are real bad. And I have seen someone discover atleast 1 bug in python
Frequent the #python channel on irc.freenode.net
Build something cool in Python and share it with others. Small values of cool are still cool. Not everyone gets to write epic, world-changing software.
Every problem solved well using Python is a way of showing how cool Python is.
I guess one way would be to help with documentation (translation, updating), until you are aware enough about the language. Also following the devs and users mail groups would give you a pretty good idea of what is being done and needs to be done by the community.
I see two ways of going about it: working on Python directly or working on something that utilizes Python
Since you're a beginner, you're probably hesitant to work on the core Python language or feel that you can't contribute in a meaningful way, which is understandable. However, as a beginner, you're in a good position to help improve documentation and other items that are essential to learning Python.
For example, the Python tutorial is less of a tutorial (in the standard sense) and more of a feature listing, at least in my opinion. When I tried to learn from it, I never got the feeling that I was building up my knowledge, like creating an application. It felt more like I was being shown all the parts that make up Python but not how to put them together into a cohesive structure.
Once I became more comfortable with the language (mostly through books and lots of practice), I eventually wrote my own tutorial, trying to provide not only the technical information but also lessons learned and "newbie gotchas".
Alternatively, you can contribute to the Python world by using Python in programs. You can contribute to projects already established, e.g. Django, PyGame, etc., or you can make your own program to "scratch an itch". Either way, you not only build your knowledge of Python but you are giving back to the community.
Finally, you can become an advocate of Python, encouraging others to learn the language. I kept suggesting to my supervisor at my last job to use Python rather than Java when a considering what to use for a new project. I tell everyone I know about the joys of Python and encourage them to give it a try. I convinced the administrator of a computer forum I frequent to create a section for Python. And, as I already said, I wrote a tutorial for Python and I'm working on a new one for wxPython.
There are many ways you can contribute to Python that aren't necessarily programming related. As your programming skills grow, you may want to move further into code contributions. But you may gain more satisfaction by helping others find the same joy you found in Python.
If you aren't up to actually working on the Python core, there are still many ways to contribute.. 2 that immediately come to mind is:
work on documentation.. it can ALWAYS be improved. Take your favorite modules and check out the documentation and add where you can.
Reporting descriptive bugs is very helpful to the development process.
Get involved with the community: http://www.python.org/dev/
Start by contributing to a Python project that you use and enjoy. This can be as simple as answering questions on the mailing list or IRC channel, offering to help with documentation and test writing or fixing bugs.