Table of Contents

Module: reflect Twisted-0.17.4/twisted/python/reflect.py

Standardized versions of various cool things that you can do with Python's reflection capabilities. This should probably involve metaclasses somehow, but I don't understand them, so nyah :-)

Imported modules   
import cStringIO
import failure
import reference
import string
import sys
import types
Functions   
_reclass
accumulateBases
accumulateClassDict
accumulateClassList
addMethodNamesToDict
allYourBase
currentThread
funcinfo
getcurrent
isLike
isSame
isinst
macro
modgrep
namedModule
namedObject
objgrep
prefixedMethodNames
qual
refrump
safe_repr
  _reclass 
_reclass ( clazz )

  accumulateBases 
accumulateBases ( classObj,  l )

  accumulateClassDict 
accumulateClassDict (
        classObj,
        attr,
        dict,
        baseClass=None,
        )

Accumulate all attributes of a given name in a class heirarchy into a single dictionary.

Assuming all class attributes of this name are dictionaries. If any of the dictionaries being accumulated have the same key, the one highest in the class heirarchy wins. (XXX: If "higest" means "closest to the starting class".)

Ex::

| class Soy: | properties = {"taste": "bland"} | | class Plant: | properties = {"colour": "green"} | | class Seaweed(Plant): | pass | | class Lunch(Soy, Seaweed): | properties = {"vegan": 1 } | | dct = {} | | accumulateClassDict(Lunch, "properties", dct) | | print dct

{"taste": "bland", "colour": "green", "vegan": 1}

  accumulateClassList 
accumulateClassList (
        classObj,
        attr,
        listObj,
        baseClass=None,
        )

Accumulate all attributes of a given name in a class heirarchy into a single list.

Assuming all class attributes of this name are lists.

  addMethodNamesToDict 
addMethodNamesToDict (
        classObj,
        dict,
        prefix,
        baseClass=None,
        )

addMethodNamesToDict(classObj, dict, prefix, baseClass=None) -> dict this goes through classObj (and it's bases) and puts method names starting with prefix in dict with a value of 1. if baseClass isn't None, methods will only be added if classObj is-a baseClass

If the class in question has the methods prefix_methodname and prefix_methodname2, the resulting dict should look something like: {"methodname": 1, "methodname2": 1}.

  allYourBase 
allYourBase ( classObj )

A list of all bases of a particular class object.

  currentThread 
currentThread ()

  funcinfo 
funcinfo ( function )

this is more documentation for myself than useful code.

  getcurrent 
getcurrent ( clazz )

  isLike 
isLike ( a,  b )

  isSame 
isSame ( a,  b )

  isinst 
isinst ( inst,  clazz )

  macro 
macro (
        name,
        filename,
        source,
        **identifiers,
        )

macro(name, source, **identifiers)

This allows you to create macro-like behaviors in python. See twisted.python.hook for an example of its usage.

  modgrep 
modgrep ( goal )

  namedModule 
namedModule ( name )

Return a module give it's name.

  namedObject 
namedObject ( name )

Get a fully named module-global object.

  objgrep 
objgrep (
        start,
        goal,
        eq=isLike,
        path='',
        paths=None,
        seen=None,
        )

An insanely CPU-intensive process for finding stuff.

  prefixedMethodNames 
prefixedMethodNames ( classObj,  prefix )

A list of method names with a given prefix in a given class.

  qual 
qual ( clazz )

  refrump 
refrump ( obj )

  safe_repr 
safe_repr ( obj )

safe_repr(anything) -> string Returns a string representation of an object (or a traceback, if that object's __repr__ raised an exception)

Classes   
Accessor

Extending this class will give you explicit accessor methods; a

Promise

I represent an object not yet available.

QueueMethod

I represent a method that doesn't exist yet.

Settable

A mixin class for syntactic sugar. Lets you assign attributes by

Summer

Extend from this class to get the capability to maintain 'related

ThreadAttr

Table of Contents

This document was automatically generated on Sat Apr 20 01:31:23 2002 by HappyDoc version 2.0