Ask Your Question
0

how to write different modules/functions in different files?

asked Jul 1 '14

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.

1 answer

Sort by » oldest newest most voted
1

answered Jul 2 '14

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.

link

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: Jul 1 '14

Seen: 375 times

Last updated: Jul 01 '14