Mar-12-2019, 01:57 AM
Hi, I published a package in PyPI and I'm able to import it. The thing is that to use the functions that the package includes which are two functions, one called encrypt_text and another one called decrypt_text, I need to import them like this:
setup.py:
from w_encryption.encrypt_text import * print(encrypt_text('Hello'))My question is: How do I change this so I'm able to import them like:
from w_encryption import encrypt_textor importing like this:
import w_encryptionIf I import the module in those two ways I get this error:
Error:Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable
Do I have to edit the __init__.py file? Now I have it like this:name = "w_encryption" from w_encryption import encrypt_text from w_encryption import decrypt_textOr do I have to edit the setup.py file outside the folder where the functions files are and where __init__.py is?
setup.py:
import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="w_encryption", version="1.0.1", author="Francisco Wendeburg", author_email="[email protected]", description="w_ncryption is a Python library that can encrypt and decrypt text.", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/fwendeburg/w_encryption", packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Topic :: Utilities", "Topic :: Security :: Cryptography", ], )Thanks in advance for your response.