I recently created and published my own hello_world package for learning purposes, since I'm new to this I am having some issue getting the hello_world output. The link of the repo is:
https://github.com/fanik041/fsa_hello_world_package
In the cli.py
file I wrote two functions for hello_world:
from __future__ import print_function
def hello():
""" Returns a Hello, World! """
return("Hello, World!")
def say_hello():
"""Prints Hello, World again! """
print(hello())
But when I try to call the function hello()
or say_hello()
(after installing the package) the IDE can't find the functions. I tried calling it using:
from fsa_test import print_function
print_function.say_hello()
Can anyone help me out with this?
You have to import the file that contains the functions.
import fsa_test import cli
cli.say_hello()
cli.hello()
There are ways you can import those functions into the root of the package so they are more readily available.
BTW, from __future__ import print_function
is only necessary if you are running Python 2.
Your execution code is incorrect. When you change to their code, everything runs fine.
from fsa_test.cli import say_hello
say_hello()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.