0

I have a ipynb file called function_list that has this code

'''
Hello, This is autoprinted on importing this module for additional information enter 
help(function_list)
'''
def add(a,b):
    ''' prints addition'''
    print(a +b)
def sub(c,d):
    ''' prints subtraction'''
    print(d - c)
def state(string):
    ''' prints a string'''
    print(string)
!jupyter nbconvert --to script function_list.ipynb

When I import this with

from function_list import *

in another file it works, but if I type help(function_list) it throws the error

error: name 'function_list' is not defined. If I import the functions with just

import function_list 

it does not import all the functions.

both dir and help didn't work.

I used this link.

How to list all functions in a Python module?

user9995331
  • 155
  • 5
  • using `import function_list` works fine for me – Rakesh Jul 16 '18 at 13:21
  • Sorry I should have clarified, if I do that help(function_list) and dir(function_list) both work, BUT you can't call all the functions when you import that way. You have to use both import function_list and from function_list import * to acquire the functions and import the file name. I was trying to state one statement and gets the whole file. – user9995331 Jul 16 '18 at 13:25
  • You can use `import function_list` and then use `function_list.YOUR_Method` to call. Ex: `function_list.add(1,3)` – Rakesh Jul 16 '18 at 13:26

1 Answers1

1

You can use help on module using below syntax

Ex:

import function_list 
print(help(function_list ))

And to call the function inside use

function_list.add(1,3)    #-->4
function_list.sub(1,3)    #-->2
function_list.state("Hello")   #-->Hello
Rakesh
  • 81,458
  • 17
  • 76
  • 113