How do I import a module from within a Pycharm project?

Tags: python pycharm

In my project, the file structure is as follows:



I have a statement in that says "import script1", and Pycharm says no module is found. How do I fix this?


To import as object :

from root.folder1.folder2 import script1

To import a function of your script:

from root.folder1.folder2.script1 import NameOfTheFunction

I think the issue is probably with deleteItem(item); in your item.jsx. You need to say this.props.deleteItem(item);.

Also, in the same method, you are doing e.preventDefault() and e is not even passed. So pass e to your method to use it.

in this line const newState = this.state.items;, you are getting same reference to state instead of returning a new one for mutation as well as using const which is used for constants while you are mutating it in the same method. I would suggest doing let newState = this.state.items.slice(); to get a fresh copy.

in here newState.splice(newState.indexOf(item), 1);, you could assign the index to a variable since you are using it twice in the method.

You need a logical condition in the while. Perhaps

By : nicomp

This video can help you solving your question :)
By: admin