In yesterday's class of the Python-infused Linear Algebra course I'm taking, a fellow student noted the strange ordering of items in a set when printed. It seemed that the printed order of the set items always swapped the first two items, but left the rest unchanged. I don't know what sets he tried, but I was interested in the general behavior, and so began my quest through the Python source code...
I have carved out a small slice of the great Intarwebs to share with you my goings on.
Showing posts with label code. Show all posts
Showing posts with label code. Show all posts
Wednesday, February 15, 2012
Set ordering in Python: why I didn't sleep last night
Labels:
code,
programming,
projects,
python
Location:
217 Thayer St, Providence, RI 02906, USA
Sunday, August 21, 2011
Genericizing Rails view templates
In keeping with my previous post, I have put together a way of greatly reducing the redundant code in Rails views. On the HTML side, this really only applies to the simple case of rendering the default REST views provided by Rails' scaffolding mechanism.
Rather than have an
Rather than have an
index.html.haml (or erb if you're a bad person ;) for every model you have, why not consolidate all of those into a single template? They all do the same thing anyway: render a table of objects along with a few actions. Using the wonderful render_inheritable gem, you can define a single index.html.x file in a central location (such as app/views/application) and have all of the customization occur at runtime.
Subscribe to:
Posts (Atom)