Still confused on global scope

right. You also might want to check out staticmethod() and classmethod(), which, by the way, seem to be poorly documented on the web.

Also, remember that "global" in python means global to the module scope. I find I never need it, and rarely use it.

-Chris

···

gary.h.merrill@gsk.com wrote:

Beware, there is a difference between the instance variable 'self.whatever' and the class variable 'Foo.whatever' where 'Foo' is the class name.

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Yes, I was going to suggest that you probably
didn’t really want a “global”. But since I don’t know you’re
entire context and didn’t want to delve into detailed analysis …

I’ve also used classmethod() and staticmethod()
in the past. It was an interesting learning experience, but after
I had done it I decided it really wasn’t smart (for my purposes) and ripped
it all back out. These things do have uses, but I think that in
general if you find yourself attracted to the use of “globals”
in Python classes, you probably don’t have quite the right design in mind.

And as Chris says, the sense of “global”
in Python is so very … well … relative. More like “locally
global” or “pretty global” or “mostly global”
or “almost global enough”. :slight_smile:

···

Gary H. Merrill

Director and Principal Scientist, New Applications

Data Exploration Sciences

GlaxoSmithKline Inc.

(919) 483-8456

“Chris Barker”
Chris.Barker@noaa.gov

02-Aug-2004 19:48

Please respond to wxPython-users@lists.wxwidgets.org

To

wxPython-users@lists.wxwidgets.org
cc

Subject

Re: [wxPython-users] Still
confused on global scope

`gary.h.merrill@gsk.com wrote:

Beware, there is a difference between the instance variable

‘self.whatever’ and the class variable ‘Foo.whatever’ where ‘Foo’
is the

class name.

right. You also might want to check out staticmethod() and

classmethod(), which, by the way, seem to be poorly documented on the web.

Also, remember that “global” in python means global to the module
scope.

I find I never need it, and rarely use it.

-Chris

Christopher Barker, Ph.D.

Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959
voice

7600 Sand Point Way NE (206) 526-6329 fax

Seattle, WA 98115 (206) 526-6317 main
reception

Chris.Barker@noaa.gov


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

`

Yes, I was going to suggest that you probably didn't really want a
"global". But since I don't know you're entire context and didn't want to
delve into detailed analysis .......

I've also used classmethod() and staticmethod() in the past. It was an
interesting learning experience, but after I had done it I decided it
really wasn't smart (for my purposes) and ripped it all back out. These
things *do* have uses, but I think that in general if you find yourself
attracted to the use of "globals" in Python classes, you probably don't
have quite the right design in mind.

And as Chris says, the sense of "global" in Python is so very ... well ...
relative. More like "locally global" or "pretty global" or "mostly
global" or "almost global enough". :slight_smile:

I normally agree with not using globals. I have seldom used them when
programming. But the application is one that I think is benign enough to
warrant it. Thanks though.

--vicki