0

Hi everyone I have a question but I don't know if it can be done in python.

Ok so this is what I want to do:

I have two scripts

string = "hello world"

and

def output():
	print string

Now what I want to do is have both scripts in different files, but when I run the file with the second script I would get it to print "hello world", from the other file. I hope that makes sense and is it possible in python?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Zetlin
0

Save the first script as myhello.py and dont use string since that is a module in Python ...

# save this module as myhello.py
message = "Hello World!"

Nor write your code to test the module ...

# module myhello.py was saved in the working folder

import myhello

def output(message):
    print(message)

output(myhello.message)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.