Namespaces for Children
Here's an excerpt of stuff posted to Wwwanderers (another Yahoo! group I frequent). My purpose is sharing it here is to suggest how some classrooms *might* be introducing the concept of namespaces to children, using chemistry and Sim Earth style simulations for themes. More on PHYSOC this month: http://listserv.uark.edu/archives/physoc.html ==== sample session slash source code ===
from ecology import StateOfMatter StateOfMatter.Gas """ StateOfMatter.Gas:
molecular degrees of freedom maximal though not excited to plasma state (vertex-bond universal joint symbol). """
StateOfMatter.Liquid """ StateOfMatter.Liquid:
more hinge-like and fluid, as if edge bonded (but not really -- the math is actually quite complicated!) """ etc. Plus inside SolarSystem.py we find: class Planet (OrbitingObject) : """ A dynamic of gases, liquids and solids, plus radiation and gravity. Gibbs Phase Rule pertains. Please subclass this Planet for your own Planet classes. """ def __init__(self, theplanet = "Earth", time = "2007 AD") # default # self.__dict__ local namespace gets # populated from SQL database by # Gas, Liquid and Solid objects pass def run(self): # gets us going, called from default # Solarsystem object pass def orbit(self): # some mechanical model goes here # (take your best shot -- Newton's # is pretty cool), or accept superclass # default pass def collide(self, other): # if thinking to play a game of # Velikovskian Pool (not my game, # but some like it...) pass def main(): mysun = Sun() myplanet = Planet() mysun.add(myplanet) mymoon = myplanet.add(Moon()) mysolarsystem = SolarSystem(mysun, planets = (myplanet,)) mysolarsystem.run() # whatever business rules so...
from solarsystem import main # not case sensitive
solarsystem.main()
Kirby
participants (1)
-
kirby urner