[Zope] how to create a module global variable ?

Stefan H. Holek stefan@epy.co.at
Thu, 03 Apr 2003 19:50:30 +0200


Ah! Then what Andreas said applies. ;-)

Stefan


--On Donnerstag, 03. April 2003 11:14 +0200 Jerome Alet 
<alet@librelogiciel.com> wrote:

> On Thu, Apr 03, 2003 at 10:49:32AM +0200, Stefan H. Holek wrote:
>> You have to use global because you are assigning to _MySharedVar. The
>> _markers are never assigned to so they do not need global.
>
> I beg to disagree. The "if" is causing the exception, not the following
> line on which the assignment takes place. At least that's the line
> number which is reported (could it be false ?).
>
> With the global keyword it works but I still don't understand why...
>
> Thanks anyway.
>
>> >
>> >    def myMethod(self) :
>> >        """My method."""
>> >        if _MySharedVar is None :
>> >            _MySharedVar = "yes"
>> >
>> > the "if" raises and UnboundLocalError, saying that I use
>> > _MySharedVar before assignment.
>
> Jerome Alet

--
Those who write software only for pay should go hurt some other field.
/Erik Naggum/