TypeError: 'module object is not callable'

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Sep 3 12:42:43 EDT 2007


On Mon, 03 Sep 2007 16:13:28 +0000, christophertidy wrote:

> Within my main.py file I have
> 
> class Main(object):
>     stepStore = StepStore()
> 
>     @staticmethod
>     def createDepSteps():
>         ....
>         stepStore.addStep([bol7, pre5])
>         .......
> 
>     @staticmethod
>     def processSteps():
>         for step in stepStore.stepList[:]:
>         ......
> 
> Main.createDepSteps()
> Main.processSteps()


What's `Main` useful for?  Is Java shining through again?  A class with
just static methods isn't a class but just a container for functions.  But
functions usually live in modules in Python so get rid of that class and
move the functions to module level.

> Trying this approach I am getting a error saying with the
> processSteps() method, stepStore is undefined

`stepStore` is searched in the function and then in the module.  But it
is defined in the class.  So you have to access `Main.stepStore`.  Unless
you are modifying `stepStore.stepList` while iterating over it, you don't
need to make a copy by the way.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list