[Tutor] subclassing Exceptions

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sat, 21 Jul 2001 20:41:06 -0700 (PDT)


On Sat, 21 Jul 2001, Sheila King wrote:

> :file in the Python source code.  I don't think that it will help, though,
> :in understanding how to subclass exceptions for your own use: it's in C.
> 
> Ah, source code...that doesn't come with the standard Windows install
> .exe version, does it? (It does come with the Unix installs, I'm sure.)
> I probably would have to go to python.org and grab it.
> 
> Do you think it would be that difficult for me to understand the C code?
> (I have taught C++ for the past two years to AP Comp Sci
> students...granted, an Intro level College course...not overly
> in-depth.)

The C source code isn't too hard to understand; it's certainly well
designed and modular.  I've always thought it would be cool for someone to
write a book that explains how Python works internally.

Anyway, you can download the source code here:

    http://www.python.org/ftp/python/2.1.1/Python-2.1.1.tgz

It's in tar.gz format, which is comparable to the 'zip' format on Windows.  
WinZip should be able to handle it gracefully, and you can just unzip it
to a convenient location.


> :Take a look at the library, and see how it defines and uses subclasses
> :exceptions.  If you have questions, feel free to ask.  Good luck!
> 
> Thanks heaps for these pointers, Danny. I will look the examples over
> and ask if I have questions.

No problem.  (Oh, guess what?  I'll be visiting my parents in Northridge
next week.  Maybe we could meet for coffee then.  It would be pretty neat
to say hi in person, no?  *grin*)



> Should I just forego downloading the Python C source?

The source code is useful, but you probably don't need to download it in
its entirety.  If there's a particular C source file that you're
interested in, you can use the SourceForge system to browse it:

   http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/


Good luck to you.