Ask Your Question
0

how to write different modules/functions in different files?

asked 2014-07-01 04:48:25 -0500

sagar gravatar image

I want to write different modules in different files. But when i use 'psspy.' functions other than in the main file error like "psspy not defined" comes.

Even if I try to import the psspy in all the files the error comes.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-07-01 20:27:13 -0500

Eli Pack gravatar image

You can pass the reference to psspy between files in the function arguments. Lets say you're running one Python file, and you call a function from another file. In the second file, you'd have a function like:

def get_data_from_psse(psspy):
    # code here
    return data

Then, in the main file that you're running, you can import psspy and just pass it to your function in the other file:

import psspy
import other_file
data = other_file.get_data_from_psse(psspy)

I'm not sure that this is the best method, but it works for me.

edit flag offensive delete link more

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: 2014-07-01 04:48:25 -0500

Seen: 369 times

Last updated: Jul 01 '14