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.

2
  • 2
    from icclim.util import callback should suffice Commented Aug 6, 2019 at 6:17
  • 2
    what about import from icclim.util import callback ? Commented Aug 6, 2019 at 6:18

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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
@ZiloreMumba see this question about this problem stackoverflow.com/questions/16981921/…
0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.