Global in multiple files
arturs at iidea.pl
Sun Jun 10 16:58:53 CEST 2001
On Sun, 10 Jun 2001 17:21:18 +0400 (MSD), Roman Suzi <rnd at onego.ru> wrote:
>>So, I thought I might be smarter than it. I would pass this
>>variable to where I need it, but... it stil obstinately refuses to
>>work. But then, my ex-global is a list of instances of a class,
>>and methods in instances of another class won't accept it as
>Why do you need global variable in the OOP design anyway?
I knew you would say that! ;)
The source code is at http://arturs.iidea.pl/server.py
and you can get 'live demo' by
$ telnet arturs.iidea.pl 2211
It's based on simple chat code.
I just want to keep this one little global, userlist, in order
not to do some strange acrobatics later. It's clean, simple,
keeps the number of arguments to pass to ther functions small etc.
>I blame myself each time I maintain code with global variables:
>the code can't be easily reconfigured, creates other problems.
>Globals are allright only in short scripts which has no chance
>to grow larger.
In this case it fits perfectly. I need to acces userlist from any place,
OK, suppose I want to do away with global userlist.
I want to pass it to TS_Command instance. Will it work? No. Why?
I have no idea... You see, I don't want to stick fanatically to my
global, any solution is fine, provided that I can split my code
and see it working as before, when it was all in one file.
This 'userlist' is my last obstacle.
"Jakos nie kusi mnie perspektywa zostania wsiowym glupkiem
znajacym sie tylko na komputerach i zarabiajacym mnostwo kasy" -- lcamtuf
More information about the Python-list