1

When I try and import my file into Jupyter using

from fatigue import *

it says

File "myfile.py", line 189
    def effectiveness():
         ^
SyntaxError: invalid syntax

It gives this error in my Atom IDE. Also when I try to run it in Jupyter, I get the same error. It is the only error the IDE is showing for the whole .py file.

I am just not sure what to do?

Ani Menon
  • 27,209
  • 16
  • 105
  • 126
Runner Bean
  • 4,895
  • 12
  • 40
  • 60
  • 5
    Chances are it is the line above `def effectiveness():` in `myfile.py` that has the syntax problem. – idjaw Nov 26 '16 at 04:38
  • The information you've provided should not give this type of error. We will suggest you to look just before and after this line, see if you implemented the function properly or miss-indented somewhere. – Ahsanul Haque Nov 26 '16 at 04:40
  • 1
    Check if there is any open parenthesis before your method or something wrong before its declaration. – Chiheb Nexus Nov 26 '16 at 04:46

1 Answers1

1

Looks like you have a error in the effectiveness() function, inside your myfile.py, so when you import this file to your main one, you get that error.

So, first of all, resolve the error back in your myfile.py, then it should work fine! Also, I recommend you to use import fatigue instead of from fatigue import *, it's much better ;)

wj127
  • 118
  • 1
  • 12
  • why is import fatigue instead of from fatigue import * better? – Runner Bean Nov 26 '16 at 04:50
  • `import fatigue` isn't necessarily "much better" than `from fatigue import *`. It can be argued that it makes your code easier for people to interpret, by explicitly showing what library a function came from, however saying it's "much better" is fairly vague. – Jason Nov 26 '16 at 04:51
  • @RunnerBean As I said before, `fatigue.function()` is clearer than `function()`, however that's the only difference. – Jason Nov 26 '16 at 04:52
  • Actually, the answers [here](http://stackoverflow.com/questions/2386714/why-is-import-bad) explain why `import *` is not the best choice. – idjaw Nov 26 '16 at 04:56
  • @RunnerBean: as Siganl said, there's not a huge difference, but in my case is much better, but just as a personal opinion. If you want to know a bit more, take a look at this link: http://stackoverflow.com/questions/710551/import-module-or-from-module-import – wj127 Nov 26 '16 at 04:57