Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the analog for .Net InvalidOperationException in Python?

What is the analog for .Net InvalidOperationException in Python?

like image 981
Konstantin Spirin Avatar asked Mar 31 '10 16:03

Konstantin Spirin


People also ask

How do you raise an exception in Python?

As a Python developer you can choose to throw an exception if a condition occurs. To throw (or raise) an exception, use the raise keyword.

What is InvalidOperationException in C#?

InvalidOperationException is used in cases when the failure to invoke a method is caused by reasons other than invalid arguments. Typically, it is thrown when the state of an object cannot support the method call. For example, an InvalidOperationException exception is thrown by methods such as: IEnumerator.


1 Answers

There's no direct equivalent. Usually ValueError or TypeError suffices, perhaps a RuntimeError or NotImplementedError if neither of those fit well.

like image 87
Ignacio Vazquez-Abrams Avatar answered Oct 02 '22 16:10

Ignacio Vazquez-Abrams