Python help, can we put class into package without modules?

Need help with C, C++, perl, python, etc?

Python help, can we put class into package without modules?

Postby fender0107401 » 2020-04-07 14:43

https://docs.python.org/3/tutorial/modu ... l#packages

Code: Select all
sound/                          Top-level package
      __init__.py               Initialize the sound package
      formats/                  Subpackage for file format conversions
              __init__.py
              wavread.py
              wavwrite.py
              aiffread.py
              aiffwrite.py
              auread.py
              auwrite.py
              ...
      effects/                  Subpackage for sound effects
              __init__.py
              echo.py
              surround.py
              reverse.py
              ...
      filters/                  Subpackage for filters
              __init__.py
              equalizer.py
              vocoder.py
              karaoke.py


Looks like packages can contain modules and modules can contain functions or classes.

I need to define one package and put a few class definition files into the package directly (without modules).

Code: Select all
foo/
      __init__.py           
          class_01.py
          class_02.py
          class_03.py


I have tried this way, but python show me: module object is not callable.
User avatar
fender0107401
 
Posts: 50
Joined: 2014-05-10 11:42

Re: Python help, can we put class into package without modul

Postby neuraleskimo » 2020-04-07 15:27

fender0107401 wrote:I have tried this way, but python show me: module object is not callable.


There are people here that are better at Python than me, but I would take a close look at your code that uses the classes. In particular, look for case mismatches in imports and class construction. Also, look for typos and spelling for class construction.
Black Lives Matter
neuraleskimo
 
Posts: 195
Joined: 2019-03-12 23:26

Re: Python help, can we put class into package without modul

Postby pylkko » 2020-04-07 16:16

Is it possible for you to explain in more detail what you want? You do not want to put the definitions simply in a module? Because most of the time people use packages to contain multiple modules. If you don't need this, then you should be able to just put the class/whatever definitions in one module. Or did I not understand what the problem is?
User avatar
pylkko
 
Posts: 1793
Joined: 2014-11-06 19:02


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable