0

This is not really a python question, but rather seeking assistance on interpretation of the syntax in my python code. I have very little knowledge of python. I have a call to an external module (i.e. external to python) as follows:

from icclim import icclim.util.callback as callback

When I run my code, I get the error

from icclim import icclim.util.callback as callback
                         ^
SyntaxError: invalid syntax

I have the icclim software installed and I see on the directory structure there is

$HOME/icclim-master/icclim/util

Inside the util dorectory I see among the files there is

callback.py
callback.pyc

My thinking is that it is one of these two files being called. The command

from icclim import icclim

works. My question is how should I make the call to callback, or do I have to set any path to callback? assistance will be appreciated.

milanbalazs
  • 4,811
  • 4
  • 23
  • 45
Zilore Mumba
  • 1,346
  • 4
  • 23
  • 33

2 Answers2

1

from icclim.util import callback does the trick.

You can only navigate through subpackages by "." symbol between "from" and "import" statements, so first you're navigating to "icclim.util" subpackage and then importing "callback" from there.

Pavel Shishmarev
  • 1,335
  • 9
  • 24
  • Thanks @Shishmarev and the same answer also by Greluchon and MjZac. I believe that is the correct answer. But then it throws me another error on a different line, which is from . import set_globattr ImportError: attempted relative import with no known parent package – Zilore Mumba Aug 06 '19 at 07:14
  • @ZiloreMumba see this question about this problem https://stackoverflow.com/questions/16981921/relative-imports-in-python-3 – Pavel Shishmarev Aug 06 '19 at 07:50
0

from icclim import util.callback it is enough for your problem.

See details: https://docs.python.org/3/tutorial/modules.html