Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Strange behavior of imports from local files in jupyter notebook

Context:

I had been developing some project in python and had decided to move functions which used to separate files (functions.py). I had created and imported it in my notebook. After that I added some functions to the file.

After I had reloaded the cell with import I tried to run the cell with code, which uses composition from functions.py, and found out that it wasn’t imported.

I restarted the kernel and cell comiled.

Why didn’t notebook import my file wholly? Maybe because it caсhed first time and did not read the actual file again?

Code of functions.py:

def composition(f:callable, g:callable) -> callable:
    def cmp(x):
        return f(g(x))
    return cmp

Code of project.ipynb:

Cell 1:

from functions import *

Cell2:

s = composition(lambda x: x**2, lambda x: x**4)

Error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/tmp/ipykernel_21766/3463491651.py in <module>
----> 1 s = composition(lambda x: x**2, lambda x: x**4)

NameError: name 'composition' is not defined

I use python 3.8.10 64-bit and editor is Visual Studio Code 1.61.2

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!