Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't make my python package print output

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading