TypeError: 'module object is not callable'
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Sun Sep 2 13:56:15 EDT 2007
christophertidy at hotmail.com a écrit :
(snip)
>
> I have another little question before I finish today:
> I am currently struggling to use a global variable in my static
> functions. I'll explain further
>
> 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()
>
(snip)
Marc and Diez already gave you the good answers on this (basically: get
rid of useless classes, and use plain functions instead of
staticmethods). I'd just add a couple comments:
First point: OO is not about classes, it's about objects - FWIW, the
mere concept of 'class' is nowhere in the definition of OO, and some
OOPLs don't even have that concept (cf Self and Javascript).
Second point : in Python, everything (well... almost - at least
everything that can be bound to a name) is an object. So Python's
modules and functions are objects.
Third point : "top-level" (aka 'module level', aka 'globals') names
(names defined outside classes or functions) are in fact module
attributes. So, to make a long story short, you can consider a module as
a kind of a singleton.
What I wanted to point out here is that there's much more to OO than
what one learns with Java - and, FWIW, much more to Python's object
model than what it may seems at first.
Ah, and, BTW : welcome here !-)
More information about the Python-list
mailing list