Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

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

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
User avatar
fender0107401
Posts: 52
Joined: 2014-05-10 11:42

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

#1 Post by fender0107401 »

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.

neuraleskimo
Posts: 195
Joined: 2019-03-12 23:26

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

#2 Post by neuraleskimo »

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.

User avatar
pylkko
Posts: 1802
Joined: 2014-11-06 19:02

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

#3 Post by pylkko »

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?

Post Reply