Arena  1.0
A content management system
 All Classes Files Functions Variables Pages
Library.Base.Classwork.AnObject Class Reference

The base class, from which all others are derived. More...

+ Inheritance diagram for Library.Base.Classwork.AnObject:

Public Member Functions

def init
 Initialize a new object instance. More...
 
def __init__
 Construct and initialize a new instance of AnObject. More...
 
def __del__
 Destroy the object instance. More...
 
def displayName
 Construct a "pretty" display name for the class instance, based on the name of its class. More...
 
def implements
 Determine whether the class instance is related to the specified class. More...
 
def toString
 Return a string representation of the class, suitable for output to a console or text-based device. More...
 
def __str__
 Return a string representation of the class. More...
 
def classname
 Return the name of the class from which the instance was created. More...
 
def name
 Return the name of the class. More...
 

Detailed Description

The base class, from which all others are derived.

Constructor & Destructor Documentation

def Library.Base.Classwork.AnObject.__init__ (   Self)

Construct and initialize a new instance of AnObject.

This method calls AnObject.init() and, if that routine returns False to indicate that initialization of the new instance was unsuccesful, then an exception will be raised.

def Library.Base.Classwork.AnObject.__del__ (   Self)

Destroy the object instance.

While this method can be used to clean up after an object instance, it cannot reliably do so at a given time because of the way Python manages reference counting.

Member Function Documentation

def Library.Base.Classwork.AnObject.__str__ (   Self)

Return a string representation of the class.

This method simply calls the toString() method. It is designed to allow descendants of AnObject to implement the AnObject.toString() method rather than the __str__() method, as the former is easier to type (and less ugly) than the latter.

def Library.Base.Classwork.AnObject.classname (   Self)

Return the name of the class from which the instance was created.

This method simply returns the value of Self.__class__.__name__ and is provided for aesthetic reasons (the author dislikes leading underscores).

def Library.Base.Classwork.AnObject.displayName (   Self)

Construct a "pretty" display name for the class instance, based on the name of its class.

This routine assumes that:

  1. The class name starts with "A" or "An"
  2. The class name will look pretty with a space between each upper- case character of the class name

A class named "ABalloonAnimal" would be rendered as "a balloon animal" by this method.

This method is primarily designed to be used for debugging output, such as to log files.

def Library.Base.Classwork.AnObject.implements (   Self,
  ThisClass 
)

Determine whether the class instance is related to the specified class.

This method simply calls isinstance() to determine whether the class instance is related to the specified class, either directly (it is an instance of that class) or by way of inheritance. The method is defined purely for aesthetic reasons, as it makes more sense, from an object-oriented view, to query the class to determine its inheritance rather than to query using a function that is external to the class.

def Library.Base.Classwork.AnObject.init (   Self)

Initialize a new object instance.

This method can be overridden by descendants of AnObject, where it is used to set the attributes of the class instance and prepare it for use. Why not use the inherent __init__() function for this? Because the author dislikes ugly leading underscores.

As implemented by AnObject, this routine will always return True. If a descendant class overrides this method such that it returns False, then the default constructor (inherited from AnObject) will cause an exception to be raised.

def Library.Base.Classwork.AnObject.name (   Self)

Return the name of the class.

The base implementation of this method merely returns the display name of the class; other implementations may return a different value.

def Library.Base.Classwork.AnObject.toString (   Self)

Return a string representation of the class, suitable for output to a console or text-based device.

This method is provided for aesthetics, as the author dislikes the inherent ugliness of leading underscores and so wishes to avoid defining the str() method. This method is called by the __str__() method for all descendants of AnObject, and so is indirectly called whenever the str() function is used on a descendant of AnObject.

In the base implementation, this method simply returns the value of a call to AnObject.displayName().


The documentation for this class was generated from the following file: