[Tutor] following on
steve at pearwood.info
Tue Feb 19 03:15:00 CET 2013
On 19/02/13 06:01, Matthew Ngaha wrote:
>>> understanding of how everything works.
>> Use it., Experiment with it. Break it.
>> Thats the best way. Read the source code its all available in
>> Python or C.
> Hey can you please tell me which source code youre referring too? The
> initial files that come with Python? also the C code, where can i
> locate this? is C something worth learning? why is Python code
> available in C?
If you want to learn Python programming, read other Python programs.
You will find many Python programs, of greatly variable quality, here:
You might also like to read this book:
You can see the source code used by Python modules by searching for them on your computer, then opening them in a text editor. But beware that you don't accidentally modify them, because you may break your Python installation.
Another alternative is to read the source on-line. Many pages in the Python docs link directly to the source code. E.g. this page:
links directly to the source code:
You can learn a lot from the source code of Python modules.
The source code of the Python interpreter, on the other hand, is much, much more complicated. You will probably have a lot of trouble with it, since you are unfamiliar with C, and unfamiliar with the internal C libraries used in the interpreter. But if you are feeling masochistic and want to give it a go, you will find the source code here:
Click the "Browse" link to get to the latest version.
Many people will advise that learning C is a good idea. I understand their arguments, but as an old curmudgeon I can say I don't like C and I think the world would be much better without it :-)
The Python interpreter may be written in many different languages. C is only the most common language. The "Big Four" Python interpreters are written in four different languages:
CPython (what you probably think of when you say "Python"): C
IronPython: Microsoft .Net CLR
PyPy: RPython ("Restricted Python")
but there are others:
CLPython: Common Lisp
Burp and Hope: Haskell
although some of these may be experimental, obsolete or abandoned.
> yes i will try not to reinvent the wheel, a lot of tutorials ive read
> seem to always point this out. Just out of curiousity what is a bag,
> stack or circular list? what is needed to create something like this?
> i sort of heard about a stack its a C/C++ thing i think?
You can read about data structures like stack, bag (multiset) and circular list here:
More information about the Tutor