CLRS_code | 《算法导论》书内算法代码实现v0
kandi X-RAY | CLRS_code Summary
kandi X-RAY | CLRS_code Summary
《算法导论(原书第3版)》书内算法代码实现
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CLRS_code
CLRS_code Key Features
CLRS_code Examples and Code Snippets
Community Discussions
Trending Discussions on CLRS_code
QUESTION
I'm quite new to Python und programming in general and have a bit of a problem with packages.
I made a directory called Package_Test and created a file named Test package in it called FUNCTIONS.
This package contains the init file and a file add. add contains a function, also called add that returns the sum of two given numbers.
The directory tree looks as follows:
Package_Test
Test
FUNCTIONS
init
add
I want to use the add function from the package in the file Test and tried the code below, but always get the error
Traceback (most recent call last): File "D:/CLRS_Codes/PACKAGE_TEST/Test.py", line 1, in import FUNCTIONS File "D:\CLRS_Codes\PACKAGE_TEST\FUNCTIONS__init__.py", line 2, in from add import add ModuleNotFoundError: No module named 'add'
In the add file I wrote:
...ANSWER
Answered 2017-Oct-26 at 15:52You can use import FUNCTIONS.add.add as add
or from FUNCTIONS.add import add
. Both of these methods allow you to reference the add
function by it's full name each time.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CLRS_code
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page