>>>>> [EMAIL PROTECTED] (Aahz) (A) wrote: >A> [posted & e-mailed] >A> In article <[EMAIL PROTECTED]>, >A> Piet van Oostrum <[EMAIL PROTECTED]> wrote: >>> >>> There is. >>> Inside a method there are 3 kinds of identifiers: >>> - local ones e.g. parameters and local variables >>> - global ones (actually module-level) >>> - instance variables and methods >>> >>> Because Python has no declarations there must be a different way to >>> indicate in which category an identifier falls. For globals it is done with >>> the 'global' keyword (which actually is a declaration), for instance >>> variables the dot notation (object.name) is used and the rest is local. >>> Therefore every instance variable or instance method must be used with the >>> dot notation, including the ones that belong to the object `itself'. Python >>> has chosen that you can use any identifier to indicate the instance, and >>> then obviously you must name it somewhere. It could have chosen to use a >>> fixed name, like 'this' in Java or C++. It could even have chosen to use a >>> keyword 'local' to indicate local ones and let instance ones be the >>> default. But if instance variable would be implicit, local ones should have >>> been explicit.
>A> Any objection to swiping this for the FAQ? (Probably with some minor >A> edits.) No. The global/local stuff needs a bit more nuance (assignments in the method being the criterium). -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list