* Payal, on 04.06.2010 12:10:
Hi all,
In http://docs.python.org/tutorial/errors.html#handling-exceptions it
says,
|>>> try:
| ... raise Exception('spam', 'eggs')
Why would I want to use a class for exception? I could simply use raise
w/o it?
Also the help() says,
class Exception(BaseException)
But we have used 'spam' and 'eggs'. Why?
| ... except Exception as inst:
Now what does "as inst" do here? (Is it making an instance, but how?
Aren't instances made with this, inst = Klass() ?)
These questions are like "why is the door rectangular when sheep are known to
dance in the moonlight only on dates divisible by cinnamon?".
It's rather difficult to answer.
I guess it's back to basics: read up on classes, instances, constructors.
Experiment, create a lot of small programs. Don't think about exceptions just
yet: you lack the fundamentals.
Cheers & hth.,
- Alf
--
blog at <url: http://alfps.wordpress.com>
--
http://mail.python.org/mailman/listinfo/python-list