[Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

Rick Johnson rantingrickjohnson at gmail.com
Wed Dec 26 00:42:45 CET 2012


On Tuesday, December 25, 2012 3:08:21 PM UTC-6, Dennis Lee Bieber wrote:
> Only that many of us don't believe Python has /variables/, the use
> of instance/class as a modifier is thereby moot.

What IS a variable Dennis?
#
############################################################
#                Variable (ComputerScience)                #
############################################################
# In computer programming, a variable is a storage         #
# location and an associated symbolic name (an identifier) #
# which contains some known or unknown quantity or         #
# information, a value. The variable name is the usual way #
# to reference the stored value; this separation of name   #
# and content allows the name to be used independently of  #
# the exact information it represents. [...] The           #
# identifier in computer source code can be bound to a     #
# value during run time, and the value of the variable may #
# thus change during the course of program execution.      #
############################################################
#
With that accurate definition in mind you can now understand how Python classes CAN and DO have variables, just as Python modules have variables; psst: they're called "global variables"!

Now, whilst i don't believe we should haphazardly re-define the definition of CS terms (or worse, re-invent the wheel by inventing new terms when perfectly good terms exist) I DO believe we should interpret these terms in their current context.

For instance, Python has no REAL "global variables", so we can happily refer to module level variables as global variables. However in many other languages (like Ruby for instance) we can declare REAL "global variables" that are known across all namespaces. And since Ruby also has modules which /themselves/ can contain variables, we would refer to "module level variables" as "module variables". 

> An instance method is a method that works on an instance of the
> class, whereas a class method is meant to work on the class as a
> whole

Allow me to use better terms:

  An instance method is a method that is known to an
  instance of the class only, whereas a class method is
  known to all instances and accessible from the class
  identifier

Now with that clear description in mind, apply it to variables:

  An instance method is a method that is known to an
  instance of the class only, whereas a class method is known
  to all instances and accessible from the class identifier.

This transformation is without flaw because it is based on logic and not emotion.

> ...I don't know of anyone arguing that Python does not have
> "methods".

Of course not because they would have to be insane. However, we should never adopt illogical terms just because a few folks cannot resolve the definition of the proper terms.



More information about the Python-list mailing list