Ask Your Question
1

what is psspy ierr

asked 2012-08-11 04:35:00 -0500

ShandaF gravatar image

updated 2012-08-11 04:37:26 -0500

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-08-11 18:05:01 -0500

chip gravatar image

updated 2012-08-12 13:15:45 -0500

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.

edit flag offensive delete link more

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 ( 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 gravatar imageamaity ( 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 gravatar imagechip ( 2012-08-12 13:30:45 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2012-08-11 04:35:00 -0500

Seen: 2,338 times

Last updated: Aug 12 '12