Newbie can't figure out documentation practices

sismex01 at hebmex.com sismex01 at hebmex.com
Fri May 9 16:14:19 EDT 2003


OK, this is as small as I can make it and keep it usefull:

>>> class InterpolationDictClass:
	def __getitem__(self, name):
            frame = sys._getframe(1)
            return eval(name, frame.f_globals, frame.f_locals)


>>> 
>>> idc = InterpolationDictClass()
>>> 
>>> 
>>> print "%(__name__)s" % idc
__main__
>>> gustavo = "666" # Not really, only on halloween.
>>> print "%(gustavo)s" % idc
666
>>> 
>>> something = "table"
>>> animal = "katz"
>>> cute = "baby grrl"
>>> print """
Something: %(something)s
Favorite pets: %(animal)s
Constanza: %(cute)s
""" % idc

Something: table
Favorite pets: katz
Constanza: baby grrl

>>> 





More information about the Python-list mailing list