Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: static variables Date: Wed, 02 Dec 2015 13:30:31 +0200 Organization: A noiseless patient Spider Lines: 23 Message-ID: <8737vlccko.fsf@elektro.pacujo.net> References: <565cf163$0$1612$c3e8da3$5496439d@news.astraweb.com> <565e4329$0$1612$c3e8da3$5496439d@news.astraweb.com> <565e4861$0$1587$c3e8da3$5496439d@news.astraweb.com> <565EAA1D.501@rece.vub.ac.be> <87a8ptcfvz.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198fzkWP4Ez8D1kPL933uqT" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:VTT2qo0LSWjbk1++Eggxbjt/n2U= sha1:ytHWDVdBf4WUSZ995fhDm7njUBA= Xref: csiph.com comp.lang.python:99870 Antoon Pardon : > Op 02-12-15 om 11:18 schreef Marko Rauhamaa: >> I don't know why global accessibility is such a problem. > > Some people seem to have a problem with global variables. Well, *I* don't go around defining global variables, but there are times when they are the way to go. For example, if a module function uses a regular expression, the regular expression should be compiled into a (module) global variable. Module functions and classes are global variables as well: >>> import math >>> def f(x): return -1 ... >>> math.sqrt = f >>> math.sqrt(3) -1 Marko