Stay With us
3 new comments

beginner
new

Help & Settings
About
Help
Tips

How to import only a method from other module in python

I am working with importing module syntax. I have created two python files. I have create a method in second file and want to import it in first file. My second file contains the code such as

def welcomeMessage():
    print("Welcome to python")

print("Happy Coding")

when i import it in my first file and calls the method. The second print statement also starts working. How can i stops this.

Here is my code in first file

import second
second.welcomeMessage()

(0) Replies

Please login or register to Comment or Answer