[Edu-sig] pythonic ethnography

kirby urner kirby.urner at gmail.com
Sat May 21 02:01:33 CEST 2011


I'm planning another class for Saturday Academy.  Last
year the theme for the whole convergence (at Reed
College) was "a time line", with students bouncing from
Egyptian Math to Neolithic Math to my more futuristic
(after now) Martian Math (with a science fiction theme).

This time there's a "global networking" theme and I'm
looking at archeology and ethnography as disciplines
that knit people together -- and use math, logic,
deductive skills.

Ethnography from some Future Time (translated from
not-English):

Python Nation flourished in the late Plasticene (the age
of plastics), contemporary with Monty Python and
Peter Sellers.  Its language has come down to us largely
unchanged.

Philosophical debates have swirled in its wake, linking
Russell's type-based approach to Logic (cite Ray Monk)
with post Vannevar Bush machine-based Logic (the
basis of our MEMEX etc).  The idea of virtual machines
was already well established (cite 'The Rise of Java in
Post Anglo America' by Cuervo & Nash, 2033).

Python, the language, was built around some primitive
types, namely int, str, dict, tuple, list, float, complex and
a smattering of others.

Natives also had access to set, decimal, and of course
the higher level structures we associate with Python's
continued use in biomolecular science and genomics
(you will encounter the Python lineage outside these
disciplines too of course, perhaps as Zython or Py5).

In this logical landscape, a dict type could eat other
objects, including of other types, through a lexical
"mouth" ( ) contrived in ASCII, a descendant of the
mathematical notation of Russell.  Objects stuffed
through a mouth were called "args" relating to the
human function of "arguing" that mouths often engage
in (also: ethnic pirates were known to say "arrrgh" a
lot, in addition to being argumentative).

'args' would be "met at the gate" (between scopes)
by params (parameters), in ways generally familiar
to computer language humanists, though the specifics
were (and are) a subject of some wonder.**

Example syntax (pillar str)
str.title(arg)
str.capitalize(arg)
str.endswith(arg, arg)
...

Note how these methods attach to one of the Primitive Pillars
upholding the ancestral "Superstructure of Objects" (as some
have translated the Anglophone literature of the late
Plasticene).

dict.__setitem__(inst, key, value)

was one of the "rib cage" methods (cite Kirbinalia Vol 3)
delivering dict type services to the surrounding ecosystem.
inst would need to be recognizably of the dict type, in order
for __setitem__ to perform its services.

Example:

class Dict(dict):
	"""
        OST skunkworks:  didactic dict (Holden, Urner)
        """
	def __init__(self,*args, **kwargs):
		dict.__init__(self,*args, **kwargs)
		self.peeks = 0

	def __getitem__(self, key):
		try:
		    self.peeks += 1 # charge 1 peek
		    return dict.__getitem__(self,key)
		except KeyError:
		    self.peeks = max(self.peeks-1, 0) # refund policy
		    print("No such animal") # warning: loud mouth
		    raise

	def __repr__(self):
		self.peeks += 2 # penalty!
		return "No paparazzi!"  # minimal security

	@property # to observe it is to change it (Heisenberg)
	def hits(self):
		"hit counter for dict-like object"
		self.peeks += 1
		return self.peeks

	
>>> thedict = Dict(key='value')
>>> thedict.hits
1
>>> thedict['Guido'] = thedict.get('Guido',0)+1
>>> thedict
No paparazzi!
>>> thedict.hits
4
>>> thedict['Britney']  # contemporary of Guido's
No such animal
Traceback (most recent call last):
  File "<pyshell#175>", line 1, in <module>
    thedict['Britney']
  File "<pyshell#169>", line 12, in __getitem__
    return dict.__getitem__(self,key)
KeyError: 'Britney'
>>> thedict.hits
5
>>> str(thedict)
'No paparazzi!'
>>> thedict.hits
8
>>>

== martian math chronicles ===

** "birth" on the other hand, was signified with the
vaginal ( ) placed after a Type such as dict( ), though
again with possible args, the birth canal's moving line
assembly potentially building ("constructing") instance
level characteristics such as skin and/or eye color.
Birth canal named __init__ in by the Pythonista's
Nation's chief language architect, in keeping with
the linguistic aesthetics of this early Logic (post MMX,
circa John Lennon, for those still confused about the
time line).


More information about the Edu-sig mailing list