raise

Python, rasing an exception without arguments

Hi, I would like to know the best practice about raising an exception without arguments. In the official python documentation, you can see this : try: raise KeyboardInterrupt (http://docs.python.org/tutorial/errors.html chap. 8.6) and in some differents code, like Django or Google code, you can see this : def AuthenticateAndRu...

Why is raising an NSException not bringing down my application?

The Problem I'm writing a Cocoa application and I want to raise exceptions that will crash the application noisily. I have the following lines in my application delegate: [NSException raise:NSInternalInconsistencyException format:@"This should crash the application."]; abort(); The problem is, they don't bring down the application -...

How can I programmatically generate keyDown events in Silverlight?

I have 2 textBoxes. First is visible the second is not. When keyDown event fires on first textBox I want to fire the same event on 2nd textBox, so it would react same as if user was typing in 2nd textBox. How can I do that? EDIT: I know you can do this in Windows.Forums and I was hoping that it can be done here too. My goal is to ha...

Rails ActiveSupport: How to assert that an error is raised?

I am wanting to test a function on one of my models that throws specific errors. The function looks something like this: def merge(release_to_delete) raise "Can't merge a release with itself!" if( self.id == release_to_delete.id ) raise "Can only merge releases by the same artist" if( self.artist != release_to_delete.artist ) #...

Where is the raise object in Python?

When you want to print a bunch of variables in Python, you have quite a few options, such as: for i in range(len(iterable)): print iterable[i].name OR map(lambda i: sys.stdout.write(i.name), iterable) The reason I use sys.stdout.write instead of print in the second example is that lambdas won't accept print, but sys.stdout.writ...

Python: I'm not allowed to raise exception. Are there other elegant python ways ?

My work place has imposed a rules for no use of exception (catching is allowed). If I have code like this def f1() if bad_thing_happen(): raise Exception('bad stuff') ... return something I could change it to def f1() if bad_thing_happen(): return [-1, None] ... return [0, something] f1 caller would be like this d...