catching my own exception

Nikola Skoric nick-news at net4u.hr
Sat Jun 19 09:53:04 EDT 2010


Dana Fri, 18 Jun 2010 20:01:45 +0200, 
Peter Otten <__peter__ at web.de> kaze:
> Solution: move your startup code into a separate file and have it import the 
> village module.

Excellent, thanks! Everything works now, but I still don't quite get what the problem is...

> You are importing your main script elswhere. Your code then 
> effectively becomes
>
> try:
>     # in another module
>     raise village.SomethingBuiltError 
> except __main__.SomethingBeingBuiltError:
>    print "caught"
>
> i. e. you get two versions of every class that are built from the same code 
> but not (recognized as) identical.

What I don't get is: what do you mean I'm importing my main script
elsewhere by runing "python village.py"? SomethingBuiltError is
defined in the same script that I'm runing, I didn't import it, did I?
If you could please clear it up for me... or point me to relevant
literature, that's also cool, I couldn't find this thing explained
anywhere.

Anyway, thanks for the solution!

-- 
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"



More information about the Python-list mailing list