Ask Your Question
1

what is psspy ierr

asked Aug 11 '12

ShandaF gravatar image

updated Aug 11 '12

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

1 answer

Sort by » oldest newest most voted
1

answered Aug 12 '12

chip gravatar image

updated Aug 12 '12

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.

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 gravatar imageJervisW (Aug 12 '12)

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

amaity gravatar imageamaity (Aug 12 '12)

@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 gravatar imagechip (Aug 12 '12)

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

Stats

Asked: Aug 11 '12

Seen: 2,506 times

Last updated: Aug 12 '12