Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda