Python Forum

Full Version: start interactive pyhton shell with pre-loaded custom modules
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,
I'm a beginner & giving myself a few simple projects to try to find stuff out. I'm trying to make a sort of desktop calculator in the form of a interactive python shell with some modules already loaded so i can just press a shortcut and go.
OS: kubuntu 18.04
python 3.6.9
#!/usr/bin/env python3

# import some modules
import math
import compound_interest
import check_prime


# Go to interactive mode
import code
#code.interact(local=locals())
the build-in module math works, but the self-mades ones don't (see error below). also, i'd like to suppress the version information that's printed when switching to interactive.
Error:
TypeError: 'module' object is not callable
Thanks for any help
Show us your modules, because it's working.

a.py

def a():
    print("hello")
main.py

import a
import code

>>> a.a()
hello
Thank you for replying.
It was indeed in the modules. I wrote them first as little programs and didn't realise i needed to remove the "#!/usr/bin/...".