0

I wrapped a library using ctypes but the library is getting extensive and I would like to make it into a module so I can just type import my_moule into the python console. I've saved the file in this location :C:\Users\name.ipython\extensions\my_module.py but when I try to import it into the python console I get "ModuleNotFoundError: no module named 'my_module' "

also while searching for an answer before posting this question I noticed most modules have somethings that looks like this:

class Name(Type):

def __init__(self):

do I need to further define my structure?

My question is this: am I saving the module to the right tlocation?

a shortened version of my module looks like this, I have about 10 more structures and they are much longer.:

import ctypes 
from ctypes import *

MF = (b'path_to_file')   

# Wrapping the library 
class TTag(Structure):
_fields_ = [
         ('SecondsMillie', ctypes.c_ulong),
         ('SecondsMicro', ctypes.c_ushort)]
class Event(Structure):
_fields_ = [
         ('count', ctypes.c_int),
         ('name', ctypes.c_char_p)]
class Header(Structure):
_fields_ = [
         ('fileSig', ctypes.c_ulong),
         ('refTime[6]', ctypes.c_ulong * 6)]
omri_saadon
  • 10,193
  • 7
  • 33
  • 58
eliza.b
  • 447
  • 1
  • 8
  • 16
  • You need to include a file named `__init__.py` under the folder ctypes. Python requires that file to consider folders as packages/modules. You can see a post [here] (https://stackoverflow.com/questions/448271/what-is-init-py-for) explaining the same. – Sriram Sitharaman Jul 10 '17 at 14:48
  • Possible duplicate of [What is \_\_init\_\_.py for?](https://stackoverflow.com/questions/448271/what-is-init-py-for) – Sriram Sitharaman Jul 10 '17 at 14:50

1 Answers1

0

When using a module I've created, I would save the seperate module file into my programs directory, or a sub directory of it.

I use Visual Studio 2017; so YMMV, I add a new file to my solution within Visual Studio, and Visual Studio automatically stores that file within a subdirectory of the solution (program) directory.

sugarfree
  • 1
  • 3