Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The PSSE API documentation uses a variable named ierr to hold the error code that a function returns.

ierr, buses = psspy.abuscount(sid=1)

You can call the variable whatever you want, I suspect the i in ierr comes from applying Hungarian Notation.

It's usually a good idea to check the error code. By convention (not just in PSSE) if an operation completes without an error a zero is returned. So you can do something like:

error, buses = psspy.abuscount(sid=1)
if error:
    print "WARNING: Something went wrong"

You send the error code all the way up to the top level of you program and return it exit which can be useful if your program is part of a larger flow:

if __name__ == '__main__':
    result = main(sys.argv)
    sys.exit(result)

Now a batch file calling your script can know that something went awry too.

The PSSE API documentation uses a variable named ierr to hold the error code that a function returns.

ierr, buses = psspy.abuscount(sid=1)

You can call the variable whatever you want, I suspect the i in ierr comes from applying Hungarian Notation.

It's usually a good idea to check the error code. By convention (not just in PSSE) if an operation completes without an error a zero is returned. So you can do something like:

error, buses = psspy.abuscount(sid=1)
if error:
    print "WARNING: Something went wrong"

You can send the error code all the way up to the top level of you program and return it exit which can be useful if your program is part of a larger flow:

if __name__ == '__main__':
    result = main(sys.argv)
    sys.exit(result)

Now a batch file calling your script can know that something went awry too.