<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>chrisjrn&#039;s site &#187; tucs</title>
	<atom:link href="http://chris.neugebauer.id.au/tags/tucs/feed/" rel="self" type="application/rss+xml" />
	<link>http://chris.neugebauer.id.au</link>
	<description>Indeed it is.</description>
	<lastBuildDate>Tue, 24 Jan 2012 23:06:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Cocomo: An experiment in metaprogramming in python</title>
		<link>http://chris.neugebauer.id.au/2009/06/01/cocomo-an-experiment-in-metaprogramming-in-python/</link>
		<comments>http://chris.neugebauer.id.au/2009/06/01/cocomo-an-experiment-in-metaprogramming-in-python/#comments</comments>
		<pubDate>Sun, 31 May 2009 23:16:40 +0000</pubDate>
		<dc:creator>Christopher Neugebauer</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[cocomo]]></category>
		<category><![CDATA[lightning talks]]></category>
		<category><![CDATA[metaprogramming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[tucs]]></category>
		<category><![CDATA[uni]]></category>

		<guid isPermaLink="false">http://chris.neugebauer.id.au/2009/06/01/cocomo-an-experiment-in-metaprogramming-in-python/</guid>
		<description><![CDATA[Friday saw the second edition of the UTAS Computing Society Lightning Talks, if you haven&#8217;t seen them already, I highly recommend that you check them out &#8212; this semester&#8217;s were at a very high standard indeed, and I wish I&#8217;d &#8230; <a href="http://chris.neugebauer.id.au/2009/06/01/cocomo-an-experiment-in-metaprogramming-in-python/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Friday saw the second edition of the <a href="http://blip.tv/file/2177007">UTAS Computing Society Lightning Talks</a>, if you haven&#8217;t seen them already, I highly recommend that you check them out &#8212; this semester&#8217;s were at a very high standard indeed, and I wish I&#8217;d printed out more certificates for good talks <img src='http://chris.neugebauer.id.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  My talk was a demonstration of using metaprogramming in Python, though that&#8217;s not what it seemed to be about.</p>
<h4>An introduction</h4>
<p>I went to the <a href="http://www.auc.edu.au">Apple University Consortium&#8217;s</a> Cocoa Workshop at the University of New South Wales in February of this year, it was a heap of fun, and we learnt heaps whilst there.  One of the key distinguising features of Cocoa is its use of verbose English method and attribute names, the idea being that each line of code should make a reasonable amount of sense when read aloud, hence:</p>
<pre>NSString *str = [[NSString alloc] initWithString @"Hello World!"]</pre>
<p>does indeed allocate memory to hold a string object, and initialises the newly-allocated memory with a string containing &#8220;Hello World!&#8221; (this code is highly redundant!).  Supposedly such a naming scheme allows coders to write code that is easily maintainable by the original coder, and easily learnable by people who pick up the code for the first time.</p>
<p>On the other hand, my friends, collectively known as <a href="http://planetmaclab.com">Maclab</a> (named after the room at UTAS we inhabit) have developed a rather unique vocabularly, which in particular involves replacing as many words as possible with either &#8216;thrust&#8217; or &#8216;fork&#8217;, so &#8220;Thrustingly thrust the forking forker&#8221; is not an uncommon utterance amongst my friends.  If this is indeed their usual mode of conversation, then Cocoa&#8217;s way of identifying methods and attributes is not necessarily going to be a particularly intiuitive one.  So, clearly, we need a version of cocoa that meets their needs.</p>
<h4>The setup</h4>
<p>So, conveniently, Apple provide a comprehensive version of the Cocoa API, thanks to the PyObjC project.  We can therefore use the Python bindings for Cocoa facilitate our new version of Cocoa.  Since Cocoa has a very consistent naming scheme, we can simply perform string replacement to translate from our maclab language to the standard cocoa language, using a routine somewhat like this:</p>
<pre> def translate(inp): ''' Translates an input string from key language to value language ''' for i in LANGUAGE: if i[0].islower(): inp = inp.replace(i, LANGUAGE[i]) inp = inp.replace(rtitle(i), rtitle(LANGUAGE[i])) else: inp = inp.replace(i, LANGUAGE[i]) return inp def rtitle(i): return i[0].upper() + i[1:] </pre>
<p>Here, <tt>LANGUAGE</tt> is a dictionary, with keys in the language code will be written in and values being the target language (in this case, Cocoa).  There&#8217;s not all that much of a sophisticated nature going on in here.  Now that we have a method by which we can translate our attribute accesses, we can get to the meat of the the code.</p>
<h4>The implementation</h4>
<p>To achieve the new API, we need to use a technique that I will call proxying.  This involves the use of objects whose sole purpose is to intercept attribute accesses and calls to an underlying object.  In this case, the point of intercepting the calls and accesses is to perform translation from our new objects to standard Cocoa objects.  In Python we can do this by overriding the standard attribute access and call methods.</p>
<p>First up is <tt>__getattr__</tt>, the attribute accessor method &#8212; for this, we are passed a string; the name of the attribute that we&#8217;re looking for, which we translate, and then attempt to access upon the method on the underlying object (in this case, <tt>self.__u__</tt>).  There is one slight hitch: in certain cases, we may not want to translate the attribute name.  This is true, in particular, of the attribute that represents the underlying object.  Hence we provide a <tt>REAL_ATTRS</tt> list, for which we use the default <tt>__getattr__</tt> method for.  This results in code that looks something like this:</p>
<pre> def __getattribute__(self,name): if name in REAL_ATTRS: return object.__getattribute__(self,name) else: new_objectname = "self.__u__.%s" % translate(name) new_object = eval(new_objectname) return CocomoProxy(new_object) </pre>
<p>Notice that we use <tt>eval</tt> to perform the lookup? It turns out that <tt>__getattr__</tt> doesn&#8217;t work universally, whereas . notation does &#8212; so we use that for less failover.</p>
<p>Being able to call methods on the objects is important, but slightly more difficult &#8212; we want behaviour to be maintained, so we need to make sure that proper Cocoa objects are passed as arguments, rather than the Proxy objects that you may have originally dealt with.  We can do this with Python&#8217;s argument unpacking &#8212; we build up a list of arguments, and unproxy them as necessary:</p>
<pre> def __call__(self,*a, **k): new_a = [i.__u__ if type(i) == CocomoProxy else i for i in a] new_k = dict( (translate(i), k[i].__u__ if type(k[i]) == CocomoProxy else k[i]) for i in k) return CocomoProxy(self.__u__(*new_a,**new_k)) </pre>
<p>We may also need to deal with iterators.  This can be done using a standard generator function, thusly:</p>
<pre> def __iter__(self): for i in self.__u__: yield CocomoProxy(i) </pre>
<p>Finally, there may be legitimate reasons for extracting Cocoa objects, these include printing strings, so we provide an accessor method called <tt>no_really</tt>:</p>
<pre> def no_really(self): return self.__u__ </pre>
<p>And that&#8217;s the entire implementation!  The final thing we need to do is provide a pre-proxied version of the base module for Cocoa.  Let&#8217;s call it <tt>GypsyMagic</tt>.</p>
<h4>The payoff</h4>
<p>So now that we have a working bridge from Maclab English to Cocoa English, we can take this sample code that puts some stuff into an array, and then prints it:</p>
<pre> import AppKit hworld = AppKit.NSString.alloc().initWithString_("Hello, World!") arr = AppKit.NSMutableArray.alloc().init() arr.addObject_(hworld) arr.addObject_("Boop!") for i in arr: print i </pre>
<p>And write it in the far more palatable:</p>
<pre> from cocomo import GypsyMagic hworld = GypsyMagic.OGMouthWords.subsume().makeGogoWithMouthWords_("Hello, World!") arr = GypsyMagic.OGForkableTrinketHolder.subsume().makeGogo() arr.thrustinglyThrustForker_(hworld) arr.thrustinglyThrustForker_("Boop!") for i in arr: print i.no_really() </pre>
<p>If you&#8217;re interested in seeing how it all fits together, see <a href="http://noogz.net/cocomo">Cocomo&#8217;s website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.neugebauer.id.au/2009/06/01/cocomo-an-experiment-in-metaprogramming-in-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Week in Review&#8230;</title>
		<link>http://chris.neugebauer.id.au/2008/11/21/the-week-in-review/</link>
		<comments>http://chris.neugebauer.id.au/2008/11/21/the-week-in-review/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 06:41:49 +0000</pubDate>
		<dc:creator>Christopher Neugebauer</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[exams]]></category>
		<category><![CDATA[lca]]></category>
		<category><![CDATA[lca09]]></category>
		<category><![CDATA[tucs]]></category>
		<category><![CDATA[uni]]></category>

		<guid isPermaLink="false">http://chris.neugebauer.id.au/2008/11/21/the-week-in-review/</guid>
		<description><![CDATA[Time for me to enumerate a few things that have happened of late (in reverse order of occurrence, naturally), since it now seems like the time to do so. Uni I handed in my Computer Science term project today, which, &#8230; <a href="http://chris.neugebauer.id.au/2008/11/21/the-week-in-review/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Time for me to enumerate a few things that have happened of late (in reverse order of occurrence, naturally), since it now seems like the time to do so.</p>
<h4>Uni</h4>
<p>I handed in my Computer Science term project today, which, I suppose means that my academic year is now complete.  I&#8217;m fairly happy with how the semester&#8217;s progressed, every unit that I studied (including the two that I chose on a whim) has been excellent, which is more than I can say for previous semesters.  <a href="http://www.utas.edu.au/units/KMA315">Analysis</a> (Real analysis to be specific) was absolutely fantastic, and I&#8217;ll be doing my best to enrol in the follow-up <a href="http://www.utas.edu.au/units/KMA352">functional analysis</a> unit (I&#8217;ve had it suggested to me by several people, and I&#8217;m convinced), and it&#8217;s certainly made the maths major I&#8217;m now enrolled in seem like a very good idea.</p>
<p>As far as I can tell, exams went well, but I won&#8217;t know for certain until results are released next week (I&#8217;m very confident with my two maths units, Graphics is a different story (though I don&#8217;t recall doing as badly as the lecturer claims the class as a whole went)).</p>
<h4>TUCS</h4>
<p>In other (though slightly Uni-related) news, <a href="http://www.tucs.org.au">TUCS (The UTAS Computing Society)</a> had its Annual General Meeting for 2009 last week, and as well as discovering the joy of barbecued* Woolworths&#8217; <em>Quantity Burgers</em> (they&#8217;re excellent, really!), I was elected society president for 2009.  The rest of the exec are also a truly awesome bunch of people, so the future certainly looks bright.</p>
<p> <a href="http://www.flickr.com/photos/chrisjrn/2971412408/" title="TUCS T-shirt by Christopher Neugebauer, on Flickr"><img src="http://farm4.static.flickr.com/3029/2971412408_83e3e43c17_m.jpg" width="240" height="180" padding="10" alt="TUCS T-shirt" align="left" /></a>
<p>TUCS has run some excellent events in its inaugural year: our <a href="http://www.tucs.org.au/category/tech-talks/">tech talks</a> were, in general, wildly successful, amongst other things.  Thanks to that, we&#8217;ve become what appears to be one of the most active societies on campus. I&#8217;ll be doing my best to make sure that we can replicate, or even better that next year.  (If you&#8217;re a speaker, or know any good ones, and would like to give a talk, let me know!)</p>
<p>In related news, we also took delivery of some particularly awesome TUCS-Branded T-Shirts just after exams &#8212; we&#8217;re particularly happy with how that went and will probably do it again next year.</p>
<p>(*I will definitely be approving funding for a new barbecue for the society&#8230; the current one is truly dreadful)</p>
<h4>LCA</h4>
<p>Last week-ish, I had dinner with some members of the <a href="http://www.marchsouth.org">Linux.conf.au</a> organising committee.  Though much of what was discussed must be kept under wraps (it&#8217;s thoroughly exciting, I promise!), I can tell you that the conference is shaping up to be most excellent, and if you haven&#8217;t already booked your ticket, I suggest you <a href="https://conf.linux.org.au/register/status">do so as soon as possible!</a></p>
<p>That is all for me for now, more news as it comes (I hope!)</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.neugebauer.id.au/2008/11/21/the-week-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TUCS Tech Talk Photos</title>
		<link>http://chris.neugebauer.id.au/2008/05/05/tucs-tech-talk-photos/</link>
		<comments>http://chris.neugebauer.id.au/2008/05/05/tucs-tech-talk-photos/#comments</comments>
		<pubDate>Mon, 05 May 2008 01:43:23 +0000</pubDate>
		<dc:creator>Christopher Neugebauer</dc:creator>
				<category><![CDATA[photographs]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tech Talk]]></category>
		<category><![CDATA[tucs]]></category>
		<category><![CDATA[uni]]></category>

		<guid isPermaLink="false">http://chris.neugebauer.id.au/2008/05/05/tucs-tech-talk-photos/</guid>
		<description><![CDATA[.flickr-photo { border: solid 2px #000000; }.flickr-yourcomment { }.flickr-frame { text-align: left; padding: 3px; }.flickr-caption { font-size: 0.8em; margin-top: 0px; } TUCS Tech Talk #1, originally uploaded by Christopher Neugebauer. As I mentioned previously, TUCS had its first tech talk &#8230; <a href="http://chris.neugebauer.id.au/2008/05/05/tucs-tech-talk-photos/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">.flickr-photo { border: solid 2px #000000; }.flickr-yourcomment { }.flickr-frame { text-align: left; padding: 3px; }.flickr-caption { font-size: 0.8em; margin-top: 0px; }</style>
<div class="flickr-frame"> <a href="http://www.flickr.com/photos/chrisjrn/2461546258/" title="photo sharing"> <img src="http://farm4.static.flickr.com/3029/2461546258_ca0d9704d8.jpg" class="flickr-photo" alt="" /></a> <br /> <span class="flickr-caption"> <a href="http://www.flickr.com/photos/chrisjrn/2461546258/">TUCS Tech Talk #1</a>, originally uploaded by <a href="http://www.flickr.com/people/chrisjrn/">Christopher Neugebauer</a>. </span></div>
<p class="flickr-yourcomment">	As I mentioned <a href="/website/blog/life/20080503-TucsLaunch.html">previously,</a> TUCS had its first tech talk on Friday (delivered by myself, on the topic of Introductory Python), this is the first opportunity to show off photos from it.  I was rather impressed by the turnout (there are a few people off to the side that can&#8217;t be seen in the frame).</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.neugebauer.id.au/2008/05/05/tucs-tech-talk-photos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TUCS Launch (Tech Talk etc)</title>
		<link>http://chris.neugebauer.id.au/2008/05/03/tucs-launch-tech-talk-etc/</link>
		<comments>http://chris.neugebauer.id.au/2008/05/03/tucs-launch-tech-talk-etc/#comments</comments>
		<pubDate>Sat, 03 May 2008 09:52:51 +0000</pubDate>
		<dc:creator>Christopher Neugebauer</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tech Talk]]></category>
		<category><![CDATA[tucs]]></category>
		<category><![CDATA[uni]]></category>

		<guid isPermaLink="false">http://chris.neugebauer.id.au/2008/05/03/tucs-launch-tech-talk-etc/</guid>
		<description><![CDATA[TUCS had its launch event yesterday, which consisted of a Barbecue, membership drive, and tech talk. The Membership front was fairly successful, given that we managed to sign up somewhere in the order of 7 new members (which is not &#8230; <a href="http://chris.neugebauer.id.au/2008/05/03/tucs-launch-tech-talk-etc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tucs.org.au/">TUCS</a> had its launch event yesterday, which consisted of a Barbecue, membership drive, and tech talk.</p>
<p>The Membership front was fairly successful, given that we managed to sign up somewhere in the order of 7 new members (which is not bad given how late in the semester it is, and that we weren&#8217;t offering Alcohol at the event <img src='http://chris.neugebauer.id.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ), hopefully we can get a few more before the end of the semester, as it would be nice to get some people who aren&#8217;t part of the &#8220;usual crowd&#8221; to join in.</p>
<p>The main reason for this post was that I delivered the tech talk, on the topic of Introductory Python.  Overall, I think it went fairly well, although I mistimed the talk such that I had to completely miss one section of the talk (which is a reminder of my debating days&#8230; but let&#8217;s not get into that).  Anyone who wants to comment on my talk (except for the sections where Bruce crashes &#8212; I already know about this) is quite welcome to &#8212; it&#8217;s available in its entirety at <a href="http://video.google.com/videoplay?docid=2129832886753561201&#038;hl=en">Google Video</a></p>
<p>The day was quite successful.  Here&#8217;s hoping that TUCS can keep getting stronger!</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.neugebauer.id.au/2008/05/03/tucs-launch-tech-talk-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TUCS Launch</title>
		<link>http://chris.neugebauer.id.au/2008/04/20/tucs-launch/</link>
		<comments>http://chris.neugebauer.id.au/2008/04/20/tucs-launch/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 23:14:25 +0000</pubDate>
		<dc:creator>Christopher Neugebauer</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[tucs]]></category>
		<category><![CDATA[uni]]></category>

		<guid isPermaLink="false">http://chris.neugebauer.id.au/2008/04/20/tucs-launch/</guid>
		<description><![CDATA[Friday was our the first meeting of the new UTAS Computing Society Executive, which incidentally, was the first under our new name (TUCS). Since then lots of progress has been made: We launched our new Website, www.tucs.org.au. We began planning &#8230; <a href="http://chris.neugebauer.id.au/2008/04/20/tucs-launch/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Friday was our the first meeting of the new UTAS Computing Society Executive, which incidentally, was the first under our new name (TUCS).  Since then lots of progress has been made:</p>
<ul>
<li>We launched our new Website, <a href="http://www.tucs.org.au">www.tucs.org.au</a>.</li>
<li>We began planning for the launch day for the new society, which is scheduled for Friday, May 2.  We&#8217;re having a barbecue, and performing a membership drive (since we didn&#8217;t do that at the start of the year, in order to get the new society in order).</li>
<li>Started a new series of Tech Talks.  I&#8217;ll be giving the first one on introductory Python, and we&#8217;re planning on making this coincide with the society launch.</li>
</ul>
<p>All in all, it&#8217;s a somewhat exciting time to be doing Computing-related stuff at UTas (here&#8217;s hoping it stays that way!)</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.neugebauer.id.au/2008/04/20/tucs-launch/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Goodbye, IDS; Hello, TUCS!</title>
		<link>http://chris.neugebauer.id.au/2008/03/13/goodbye-ids-hello-tucs/</link>
		<comments>http://chris.neugebauer.id.au/2008/03/13/goodbye-ids-hello-tucs/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 09:41:08 +0000</pubDate>
		<dc:creator>Christopher Neugebauer</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[tucs]]></category>
		<category><![CDATA[university]]></category>

		<guid isPermaLink="false">http://chris.neugebauer.id.au/2008/03/13/goodbye-ids-hello-tucs/</guid>
		<description><![CDATA[Today was the AGM for the UTas Internet Developers&#8217; Society. Other than the usual blather that occurs in AGMs for these sorts of things, we&#8217;ve approved a change of name to TUCS (or rather the Tasmania University (union) Computing Society). &#8230; <a href="http://chris.neugebauer.id.au/2008/03/13/goodbye-ids-hello-tucs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today was the AGM for the UTas Internet Developers&#8217; Society.  Other than the usual blather that occurs in AGMs for these sorts of things, we&#8217;ve approved a change of name to TUCS (or rather the Tasmania University (union) Computing Society).  For the moment this name change is purely cosmetic (as we really haven&#8217;t done that much in the way of Internet Development for as long as I&#8217;ve been at the Uni.  The new name (in my opinion) reflects the membership, and the aims of the society a lot better.</p>
<p>One item of Business that I raised was the upcoming <a href="http://www.marchsouth.org">Linux.conf.au 2009</a>, which you probably already know by now is being held at the University of Tasmania in Hobart.  It&#8217;s been resolved that the Society establish better ties with the Free Software/Open Source Community (in Tasmania, in Particular with TasLUG) with the intention of better promoting Free/Open Source software amongst the student and staff body in the leadup to the conference; and I ran for the executive (successfully) on that basis.</p>
<p>Here&#8217;s hoping it&#8217;s a successful year for the society (which now has a cool name!)</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.neugebauer.id.au/2008/03/13/goodbye-ids-hello-tucs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

