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?

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)

Thanks that was what I was looking for

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.