1

what is psspy ierr

  • retag add tags

I just began python and psse together. My colleague has a script for automating contingency study. My colleague has ierr in his codes.

What is ierr mean with Python?

Please help me, just starting Python and very confused where to look

Kind Regards

ShandaF's avatar
31
ShandaF
asked 2012-08-11 04:35:00 -0500, updated 2012-08-11 04:37:26 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

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.

chip's avatar
459
chip
answered 2012-08-11 18:05:01 -0500, updated 2012-08-12 13:15:45 -0500
edit flag offensive 0 remove flag delete link

Comments

Great tip about the Hungarian Notation @chip. When I was starting out with the psspy API, i'd often forget to tuple unpack `ierr, buses =` and just do `buses = `

JervisW's avatar JervisW (2012-08-12 04:03:43 -0500) edit

Odd that! I have been thinking all along that the i in ierr meant integer type.

amaity's avatar amaity (2012-08-12 05:37:47 -0500) edit

@amaity, that is my assumption too - the prefix `i` indicates the data type of `integer` which is the essence of systems Hungarian notation. It's not very pythonic, but the PSSE API docs use `ierr` all over the place so I'm still conflicted about the right name to give the variable.

chip's avatar chip (2012-08-12 13:30:45 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer