Thursday, 18 October 2018

python equivalent to java guava Preconditions

Does python have any equivalent to java Preconditions library. e.g.

in java, you can check the parameters like this:

public void dummymethod(Cat a, Dog b) {
   Preconditions.checkNotNull(a, "a can not be null.");
   Preconditions.checkNotNull(b, "b can not be null.");
   /**
   your logic
   **/   
}

If a or b is null, Java throws Runtime Exception, How about python, what's the best practice here for python?



from python equivalent to java guava Preconditions

No comments:

Post a Comment