I have this little bit of python code where i try to create a surface.byperimeterpoints. I want to make it that the code gives a null-value when the argument is not eligible, like the Function Apply method in the picture. Can somebody help me out on how to solve this problem in Python?
can you show the error?
the method need a list as argument
I’m willfully puting in a wrong input. I want it to give a null value without the warning if the argument is not valid.
This is generally bad coding practice, but fits in a few niche conditions.
You’ll need to proceed your action with a try statement, and then provide the except statement.
Something like this:
outcome = Surface.ByPerimeterPoints(points)
outcome = None
The reason this is bad practice is that you are concealing the issue from your end users. There is a problem, they won’t find it without reverse engineering your entire code base.
A better solution would be to provide the exception rather then the null. This can be done by modifying the except portion of the code to be something like this:
outcome = traceback.formatexec()
Thank you very much for the advice and help!