[Tutor] Slightly OT: public/private class members
alan.gauld@bt.com
alan.gauld@bt.com
Fri Feb 14 11:30:35 2003
> On this subject, why can't Python enforce variable names ( e.g.
> use strict),
Sorry, what does that mean exactly? Do you mean why doesn't
python insist in declaring variables before you use them?
I think thats what VB does with strict? Or is it a Perl
thing?... Anyway what do you mean? Why would it help?
> and why are all variables global in scope.
They aren't. Whatever gave you that idea?
Python has 3 levels of scope:
builtins, module or file(what the docs call global) and
local(inside a function). Also classes define a kind of
local scope too.
See the namespaces topic in my tutor for more info.
Alan g.
Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld/