Settling In

Posted by Unknown Senin, 22 Mei 2006 0 komentar

I moved into my new apartment a week ago. Except for one glaring problem, it’s really quite nice. The one glaring problem is huge: no internet, yet. I’ve been a happy user of cable based internet for most of the past six or seven years, from Fredericksburg to Salt Lake. I haven’t even had a phone line since moving back to SLC.




I’ve been happy enough with cable internet, having had very few problems over the past few years. But right now, COMCAST is having troubles recognizing the existence of my new building – even though the builder remembers working with COMCAST to lay the cable. It’s there, apparently, waiting for the first tenant to place a subscription order. And hey! That’s me! I don’t think it’s any major fault of COMCAST’s though… Not really anybody’s fault. But I hope it gets resolved soon.




The apartment is small, but cozy. And it’s not even really that small. This is the third in a series of living spaces that have been open plans: the only doors (besides the entrance) in my last three apartments have been for the bathroom, storage areas, and (in the case of the last two) a/c and water heater access. What differentiates the new space is that it features an upstairs loft, letting me separate the living space from the working space while still keeping everything open. It also means that the ceiling in the working space is extremely high. Actually it slopes back as it’s an arched roof.




The building is a converted warehouse. It’s a newer warehouse than the ones I was previously in, with cinderblock walls. It was one of those high ceiling single-story warehouses with the arched roofs, which is where the room for the upstairs loft comes in. The cross beams up there remain exposed (providing fun places to try to hang / tuck things). The ceiling/roof is punctuated with clear skylights, with one in the loft area that can be cracked open for ventilation. I’ve enjoyed being able to sit / lie up there while watching clouds go by. The arched roof creates an interesting sense of coziness as it slopes down away from the living space. From my reading space in the corner, the place feels snug – almost like a cabin. I can then go over to my writing desk and peer into the workspace, enjoying the open nature. But while sitting and writing, it’s never overwhelming.




Another feature across my recent series of apartments has been hard flooring. Hardwood floors in one, painted plywood/particle board (yep) floors in another, and in the new space: brushed concrete!!! Damn that’s nice. Unlike the last two apartments though, I also have carpet in the loft – a feature that my dog greatly appreciates (thin-skinned bony greyhounds love soft surfaces).




While the kitchen and bath (on the main level) and living space (loft) feature regular lights, the workspace can be illuminated by two pairs of halogen lights. Excellent for painting, drawing, recording, everything! A large modern ceiling fan in this area circulates air and drives down the need to keep the air conditioner on constantly.




Perhaps the best feature of all is the neighborhood. I’m surrounded by metal recyclers, an old concrete plant my dad worked at when I was young (primarily empty now, although its large silos still seem to be in use). Empty warehouses, active warehouses and industry, random pockets of artists, trains, overpasses, underpasses, industrial back-alleys, a pyramid, and more. It feels good to be out just-ahead of the city. My last couple of places were a little closer to the heart – different sides of the heart, though. The area I moved out of (and where my office remains) has started to feel different over the past few months, and I don’t like the feeling. It’s not bad – in fact, I’m glad my office is still here. There is a lot of interesting growth happening and on the verge of happening here. And suddenly, it felt boring. It felt too contemporary when I wanted it to feel more creative, which is strange because I lived in the actual artist block of Artspace and had some great (and creative) neighbors. But the edge was gone.




I think my last trip to New York woke me up to this feeling. I played a show in the Red Hook neighborhood of Brooklyn and fell in love. I fell into a funk as my plane landed back in Salt Lake. Over the next couple of weeks I daydreamed of a new space to live and work. I hid in old films, images, and articles of SoHo, and scoured Flickr archives for photos from different neighborhoods and cities that captured an elusive feeling that I was wanting back. My lease came up for renewal, which put me on month-to-month until I renewed, and I decided to take a serious look around at some new options. Ideally I wanted a place I could convert on my own, with a big garage door and a layout that’d let me keep the dog(s) safe on one side while I worked on the other. I don’t really have the spare time or funds to support such an endeavor at this time. Still, I decided to look around and see what was available that would allow me to separate workspace and living space, or that I could buy. This was when a flyer showed up under my door announcing the lofts that I’ve now moved into.




As I walked down to check them out, I realized that they were in the heart of the industrial area that I loved. In fact, I had been walking through that area a couple of weeks prior and had been kicking myself for not having a camera along with me. The energy of the area was more active, fresh, raw, gritty, real, and beautiful – to me anyways. And upon seeing these new spaces and their design, I signed almost immediately. A couple of weeks later, I was moved in. It all happened so fast and naturally, just a straight-ahead instinctual thing. Compared to all of the stress I’ve felt this year, it was nice to do something big that felt just right.




Best of all – the dog loves it. In fact, she seems even more playful now.




All I need now is internet.


Baca Selengkapnya ....

Tinderbox, OmniOutliner, and GTD (again)

Posted by Unknown Kamis, 11 Mei 2006 0 komentar

A few months ago I bit the bullet and purchased Tinderbox, an interesting outlining/mapping/linking application for Mac OS. I primarily purchased it to use Ryan Holcomb’s template for a Tinderbox based system for the Getting Things Done workflow, but I also dreamt of using it for more.




I haven’t used Tinderbox much in the past couple of months. Kinkless GTD 0.83 came out along with the OmniOutliner 3.6 beta (now in final release), and it solved many of the issues I had with earlier versions of the KGTD/OmniOutliner combination. Prior to OmniOutliner 3.6, there was just a single toolbar customization setting for OmniOutliner. In most Mac OS X Cocoa apps, you can customize the toolbar pretty easily. It’s just one toolbar – not the big mess of toolbars that the Office systems have become. Generally, it’s been a very handy feature.




As OmniOutliner grew terrific Applescript support, they allowed you to add your scripts to the toolbar. Kinkless GTD is, in fact, a handful of Applescripts that do an implementation of the Getting Things Done method of planning / management. By putting a few new buttons on the toolbar, you essentially got a new specialized application that took advantage of the terrific nature of OmniOutliner (still the easiest and most fluid outliner on Mac OS X, and looks great too). The downside was that if you wanted to work on other outlines, the GTD buttons would still be there even if they had nothing to do with the document you were working on.




With OmniOutliner 3.6, you can now have document specific custom toolbars, meaning that my KGTD outline no longer interferes with other outliner documents. A few other concerns were dealt with in the new KGTD release that made it feel much more natural, and I found myself switching back to the OmniOutliner/Kinkless combination as my “trusted system”.




There’s a big difference in styles between how OmniOutliner / KGTD work and how Tinderbox / GTDRules work.




About OmniOutliner + Kinkless GTD:





  • KGTD is an aggressive user of OmniOutliner’s extensive Applescript support (and in turn, OmniOutliner’s Applescript support has gotten even stronger).

  • KGTD’s main unit of work is a big synchronization script that moves and copies outline elements around. In the Getting Things Done method, you “plan in projects and work in contexts”, and often need at least two views of your actions – the plan list, and the actual “do this next in this place” list. Kinkless GTD manages both by copying/merging/moving.

  • By using AppleScript so extensively, Kinkless GTD works well with tools like Quicksilver, whose motto is “act without doing”. It’s easy to send an action into your KGTD inbox without ever switching applications or even taking your hands off the keyboard. Kinkless GTD has also done a lot of work to integrate with Apple’s iCal calendar, which in turn allows one to use various menu bar tools and Dashboard widgets to keep an eye on actions without having to bring OmniOutliner into focus. The use of applescript brings integration with other common tools.

  • However, KGTD requires manual execution of the synchronization command. It’s possible to end up with ghosts and duplicates since it’s doing so much copying and moving. It’s gotten a lot better when it comes to the ghosts and duplicates, but it means that an active action may have two or three copies in the same document, all separate outline rows.

  • OmniOutliner is a single-window application (well, single window per document). But with the new sections and navigation features in OmniOutliner 3, it’s quite easy to move around and focus on particular elements.

  • As a native and modern Mac OS X application, built by a shop with a long history of Cocoa/OpenStep/NeXTStep development, OmniOutliner also gets to take advantage of many advanced Mac OS X features. Services, text system plug-ins, etc. This includes automatic spell checking, in-place dictionary look-ups, and more (ie – with “Equation Service”http://www.versiontracker.com/dyn/moreinfo/macosx/14090 installed you can easily convert LaTeX source to a rendered PDF and back again, without OmniOutliner ever knowing anything about LaTeX)




About Tinderbox + GTDRules:





  • GTDRules is an aggressive user of Tinderbox’s system of agents and prototypes.

  • GTDRules main unit of work is a collection of agents that are always running. Agents in Tinderbox are live queries which can also act on the items that they match. In the document view(s), found items are displayed as children of the agent. Most of the agents in GTDRules are ‘contexts’ (again – plan in projects, work in contexts), showing the next actions for the office, for home, for errands, etc, under the agent.

  • Synchronization is always happening, so when an item is marked as complete, it disappears from the agent displaying it immediately.

  • Data is not duplicated – the agent results are treated as Aliases, which you can also make manually in Tinderbox. Aliases are like their desktop / file system counterparts: a symbolic link. This way, there are no ghosts or duplicates.

  • Tinderbox has a menu, customizable per document, called “Value”. You can use the Value menu to quick-stamp values on Tinderbox nodes. Since there are no checkboxes in the outline views, this is how you mark something as complete. But it’s also a way you can select many actions and set them all to be “Office” actions, in one swoop. Or put them on hold in one swoop. Customizing this menu is pretty easy.

  • GTDRules also takes advantage of Tinderbox’s “OnAdd” rule setting, allowing you to set default values for nodes added – ie, a work project can easily be set to have its children be ‘Office’ prototypes so that they show up in the Office context, but projects for an on-site customer could default to ‘Remote’ instead.

  • Tinderbox allows many windows to be open for a single document, and remembers their placement and displayed content. This allows one to take a big system like this and section it off into numerous views.

  • Tinderbox, however, is very much a classic style ‘Carbon’ application. It still feels like a custom classic Mac application, and does not take advantage of many modern Mac OS X features – even ones that are available to Carbon, such as Services. This isn’t a HUGE deal – at least it’s native – but it’s frustrating to use the Font menu when I have so many many fonts installed that are so easy to work with in Cocoa text areas (using the font browser in OS X).

  • Tinderbox has practically no Applescript support. It’s an island. Within the system there are a lot of things you can do. But you can’t easily send yourself notes from Quicksilver, from Mail rules, etc. There’s no integration with iCal or anything else. Using Tinderbox is almost like using Squeak on Mac OS X. Yeah, your mouse and keyboard and the clipboard all work, but beyond that it’s a universe unto itself.




Tinderbox’s isolation was a key figure in driving me back to Kinkless GTD / OmniOutliner. The GTDRules implementation on Tinderbox is a more “pure” implementation of the GTD workflow and easier to customize to one’s preferences (no applescript programming required). But data entry – especially of the quick “i need to remember to look at this later” variety – is not its strong suit here. There was something about it that started causing me stress when I’d look at my system. Maybe it was me getting sloppy and not cleaning / planning as well as I should. But something would just feel off.




All of that said, Tinderbox has a lot of great features that I’ve been meaning to explore. The euc.cx universe is ever growing, a great jumble of myth and fact, legend and memory. I’ve been wanting to start setting down all of the characters, locations, productions, etc, of it all and exploring the relationships. This is Tinderbox’s strong suit – links, relationships, visual maps (as well as outlines), prototypes, custom data, all should play in here. I really do need to keep myself still long enough to start learning how to do this. And I want to write again. Like really write, in hypertext, with relationships and cross references. I tried this once with ddec, a system based on an old implementation of the FTrain sitekit. But I hated writing in XML. (I just hate XML. I don’t care about it as a storage format, but I do hate writing in it, configuring in it, etc). This kind of writing is the real concept behind Eastgate as an entity. Whether anything will actually happen is hard to say at this point. But it looks like my writing desk will be in an excellent location in my new space and I hope it’ll help inspire me.




The view from where the desk will most likely be. (It’s a console table actually, just the right size for an iBook, a small lamp, a pile of notebooks, and the dog’s leash):




Eucci Sunhill, Empty


Baca Selengkapnya ....

Studio Peak (Inspirational Peek)

Posted by Unknown Jumat, 05 Mei 2006 0 komentar

As I’m getting ready to move to a new loft that will give me a nicer, more dedicated working space, I’ve found myself doing a lot more painting. I was working on large canvas in front of this stack of metal cube-ish storage things. As I was taking some pictures of the work in progress, I realized I needed to get a shot of what sits up top. Here, in bite sizes, are a lot of representative elements from artists, designers, factories, and companies that are a pretty strong source of inspiration. So, to step away from the usual crankiness and software focus for a bit, I thought I’d share a bit:



Studio Peak (Inspirational Peek)



SuperSampler, Lubitel, LCA, and Baby Holga (110 Format!) Cameras. The 120 Format “standard” Holga is on top of my desk and not with the rest of the family. I do love these cameras: they have a lot of personality, with the LC-A being my favorite point’n’shoot 35mm camera ever. I don’t do film as much these days. For a few years my walk home took me past a few places where I could get film developed (including the 110 and 120 formats), often dropping the 35mm off in the morning on the way to work and picking it up on the way home. I haven’t had that since I moved into my current place, and that’s taken a big bite out of me rolling over new rolls as often. Plus I do have the digital camera that’s great for taking endless pictures of the dog, of paintings, and flash conditions. But it’s a soulless camera compared to these guys, most of which are completely themed around a terrific (and fun) mantra: don’t think, just shoot.




Brushes, Brushes, Brushes. Some of these brushes came with me back from Virginia and are still in pretty good shape – probably because I don’t paint nearly as much as I used to. But when I got my current place I finally got that container they’re in, which has made access to my core set much easier than my previous contraptions.




Helmut Lang promotional cards (from one of the last seasons). Helmut Lang was my favorite designer, with a terrific design aesthetic that was applied to everything under the brand. The flagship store in New York, designed by Richard Gluckman, was a terrific piece of architecture. Completely opposite of most New York stores (crowded, impersonal, or overly flashy), the Helmut Lang space used design to usher you in to a private area with large aisles and easy access to everything, without ever telling you what tricks it was pulling. It was an amazingly comfortable space. There was a “complete experience” about Lang that I sorely miss.




Ryoji Ikeda ‘Formula’ DVD and Book. Another terrific aesthetic minimalist, Ryoji Ikeda’s installations and a live set are showcased in this excellent volume. Ikeda is another artist who, like Lang, seems adroit at knowing what to take away, what to shift, and what to tuck into a piece of art (design, clothing, composition).




New reissue of Pizzicato Five’s Romantique 96, in front of Merzbow ‘Senmaida’ card (making it look like Maki and the Dalmations are on a Merzbow promo here). Two more excellent Japanese artists. Pizzicato Five kept many Jet Age fashions, designs, and ideals alive in their music. Their album packaging was often a step above (with only a couple of the U.S. releases falling short). Credit cards, luggage tags, postcards, stickers, bookmarks were among the things one could find inside a common release. And of course, there were the pictures of Konishi and Maki. Beautiful music, and a favorite artist of mine for years. Merzbow is almost their opposite: harsh noise. Hundreds of releases across an almost equal number of labels and distributors. He carries on almost a pure dadaist spirit. The cover art and packaging quality can vary wildly. The noise is almost always top-notch and he remains one of the kings. The postcard (mostly hidden in this photo) is from Senmaida which featured art by Val Denham that I just had to have for the picture alone.




Stack of book size Hafler Trio and Pizzicato Five releases, more albums in excellent packaging. The Hafler Trio being another terrific inspiration on many many fronts. Among other things, The Hafler Trio has played with sound-as-high-art, putting out releases in very limited numbers and with many extras in the packaging or experience to make it especially worth obtaining.




Brazil!. On VHS. Ahhh, Terry Gilliam.




“I draw on anything for inspiration – a fond memory, a piece of paper, a wall in a train station” – Danger Doom/Talib Kwali


Baca Selengkapnya ....

Tools

Posted by Unknown 0 komentar

I’ve never been a fan of IDE’s. I grew up on Commodore 64 BASIC – always on, just start typing in code and it works. I used IDE’s a little bit way back in my high school computer science day, but I remember it as little more than an editor / compiler combination (Lightspeed Pascal on Mac System 6). After that, I did very little programming for a few years except for casual purposes until I started using Python in 1996.




Most of my Python programming career has been focused on web development, and subsequently most of my development environments have been on development servers. For a good stretch of time, my editor/environment of choice was XEmacs. A couple of years ago I switched to VIM (lighter weight, didn’t need to bother setting up X Windows any more, and I could go into a stripped down production server running bare bones VI and not feel completely lost). A couple of months ago I started using TextMate pretty heavily, and started working on my desktops again since Mac OS X is, after all, Unix. Using DarwinPorts I could get the requirements for both Zope 3 and Ruby on Rails going pretty easily. And in this “just a plain but smart editor please” camp I remained, using the terminal to start and stop servers, to debug, to watch logs, etc.




But the other day I decided to check out RadRails, an Eclipse based IDE for Ruby/Rails development.




And holy shit, I was impressed.




Traditionally IDE’s have bugged me with their ever proliferating collection of panes and tabs. Too much noise! Too much to set up! Too much fighting to make it work my way! But with a little bit of preference tweaking (to point RadRails at the right Ruby / Rails installations on my desktop), I got RadRails running. I didn’t use it heavily (I’m not doing active Rails development, but continue to check it out from a point of envy / curiosity), but I was impressed with what it had: good knowledge of the Rails Generators, the database explorer, consoles, log watchers, etc. All things that I’m sure IDE users take for granted. I was especially impressed with how easily one could maximize any pane to be full-window size, and then go back to the many-many-many-views, using just a double click.




While it still doesn’t feel 100% native, RadRails/Eclipse actually performed and behaved rather well in Mac OS X – better than any other Java application I’ve used. Better by a long shot.




Now where’s something like this for Zope 3? Especially for my bastardized system using SQLAlchemy? :)


Baca Selengkapnya ....

Snakes and Rubies in the Temple of Bondage and Discipline down in the City of Heartbreak and Needles

Posted by Unknown Kamis, 13 April 2006 0 komentar

One of the new topics making the rounds is a spate of responses to an old (2-3 years, at least) post comparing Python and Ruby. One piece of interest is this bit:





Larry Wall, the designer of Perl, has the slogan “There’s more than one way to do it”. In contrast, Bertrand Meyer, the designer of Eiffel, says “A programming language should provide one good way of performing any operation of interest; it should avoid providing two.” Ruby follows the anarchist approach of Larry Wall, while Python follows the bondage-and- discipline approach of Eiffel.





While it’s stated in the Python import this (aka “The Zen of Python”): There should be one – and preferably only one – obvious way to do it, that’s seldom the case in actuality. Ian Bicking’s response to the post linked above mentions this as well. There are well meaning attempts at consistency – but do they happen?




Python makes some interesting design trades. As many note, it’s not a so-called “Pure Object Oriented” system. You can write Python in a purely procedural style, in a Modula style, in functional style, in pure scripting style, in “pure OO” style, or in a mix of all.




The comprehensive standard library is a big mix of all of these styles. Some of it stems from certain core modules being thin layers over common C libraries. Some of it stems from different styles of different authors. Some of it stems from age.




I’ve generally been a fan of Python’s modular approach. Common modules like os and os.path provide a nice – but thin – abstraction over operating system specific behaviors, especially in regards to the file system. Python’s early development, according to legend, happened on Macs (and considering Python’s age, it should be noted that this was long before Mac OS X). Classic Mac OS, DOS/Windows, and Unix all spell paths differently. In the mid nineties, as Python was starting to really find its audience (including me), its primary rival was perceived to be Perl. Perl’s history is steeped in Unix style shell scripting. Perl scripts, then, typically had very Unix style paths and elements inside of them, just by default. While there were some good Perl implementations available for classic Mac OS, it was hard to play with other peoples code – there were just a lot of system expectations built in, especially at the time I started experimenting with the two P languages.




Python, on the other hand, had the ‘os’ and ‘os.path’ modules. These modules contain, among other things, knowledge of how the current OS spells certain file system elements, like ‘parent directory’ or path separator. Classic Mac HFS paths were separated by colons, for example, and ‘pardir’ was not ’..’ but ’::’. And, of course, Windows/DOS uses backslashes instead of forward slashes. So while you could write paths the normal way, it was (and still is) considered good design to use the os module’s tools:





pydir = os.path.join(os.pardir, 'lib', 'python')
appdir = os.path.join(pydir, 'example')


But! The os module’s elements for working with paths is very procedural. There’s not really a built in concept of a Path object. That may be changing in Python 2.5 if PEP 355 really finds its way in. Then the above could be more like:





pydir = Path(Path.cwd().parent, 'lib', 'python')
appdir = Path + 'example'


While that doesn’t look like much, it’s when one looks at some of the proposed replacements that one can see the difference:





CURRENT (using 'os')
--------------------
DIR = '/usr/home/guido/bin'
for f in os.listdir(DIR):
if f.endswith('.py'):
path = os.path.join(DIR, f)
os.chmod(path, 0755)

NEW (using 'path')
------------------
for f in Path('/usr/home/guido/bin').files("*.py"):
f.chmod(0755)


Taking that old – but useful (and usable) – procedural code and turning it into a class / objects is just beautiful, and is one of those “why didn’t they do that before?” things. The new Path class also brings a lot of functionality that’s dispersed in other modules (that people may not even be aware of) together, like ‘glob’, ‘fnmatch’, and ‘shutil’. (It looks like Ruby 1.8 picked up something similar with the new Pathname class).




The point being – this is an area where there are really quite a few ways of doing things in Python. Is it good? Is it bad? It’s a nice kind of freedom, I guess, to be able to write in both procedural/modular and OO styles. There’s definitely no hard “bondage and discipline” here.




There’s also no hard “bondage and discipline” in Python when it comes to naming. There are some good practices, but not everyone follows them (myself included). I have a personal style guide, much of it taken from practices we had at Zope corp (4 spaces indentation, must fit in 80 columns) and styles picked up over recent years (all package/module names lower case, all classes capitalized, never import * if it can be avoided, etc). And I wince when I see code that differs – mixed case package/module names being one of the biggest turn-offs to me, personally. import * has generally been offensive as well. One thing that I’ve historically liked about Python has been the ability to trace back any name I see in code. “Path… ah, it came from from path import Path! And implements.. Oh, it came from zope.interface import implements! and self.bluecheese is obviously an attribute available to the instance!” import * tends to get in the way of name chasing. I like to learn code by reading it (since most documentation tends to be flaky), so being able to find where ‘mapper’ or ‘begin’ or ‘desc’ or ‘Table’ came from is something I like. And for maintainability reasons, I’ve liked being able to find and trace names within a function/class/module without having to speculate.




But that’s just my preference. Python’s namespaces and general rules here have generally worked out for me. But as I’ve gone on, I’ve found myself much more critical of other Python code than I should be, which is contributing to this crisis of faith I’ve been going through. Whereas when I’m ready Ruby code, I have different expectations and can be a lot more forgiving.




But there’s something significant that I’ve come to realize about Ruby. It can be argued that Python’s biggest “bondage and discipline” element is its use of significant whitespace (clear structure by indentation is enforced at the language level – although there are ways around this). Ruby, on the other hand, enforces significant naming conventions. As I’ve been reading Ruby code (with most of my experience being limited to Rails and code from why the lucky stuff), I’ve grown to appreciate this:





  • Constants begin with a capital letter. Classes and modules are constants, and so they are always capitalized. Pathname.pwd, ActiveRecord::Base, and so on.

  • variables are lower case (or at least, start with a lowercase letter). This includes methods.




Understanding those two elements alone (along with learning Ruby’s symbols for self.attribute access, etc) has made it really easy to start reading and understanding Ruby code. I can understand how Rails can be a system that “prefers convention over configuration” – there seems to be a fair amount of convention enforced in the language and core library as it is.




Another thing I find interesting is that object attributes are not exposed directly, but can be exposed easily through methods. With parenthesis being optional on method calls, this makes zero-input methods (ie – ‘reader’ methods) much easier to use and work with. An historical Zope 1 and 2 problem was the case of ‘id’. Some objects would just have their ‘id’ (name within their container) set as an attribute. Others would compute it and have a callable method. In DTML and TAL, you could refer to ‘id’ and the templating language’s expression engine would figure out if it needed to be a call or not (and then translate it into ‘id()’ if needed). So sometimes, obj.id would return a string like ‘monkey’. But other times it would return (bound method id of ...). Python’s descriptors (since Python 2.2) make this a little bit better, but in my encounters with Ruby so far, it’s made code more readable and consistent and predictable. The proposed Path class for Python (mentioned above), for example, has a mix of properties and methods:





curpath = Path.cwd()
documents = curpath + 'Documents'
curpath.parent
curpath.realpath()
curpath.mtime()
curpath.isdir()
str(curpath)


Compared now to Ruby’s Pathname object:





curpath = Pathname.pwd
documents = curpath + 'Documents'
curpath.parent
curpath.realpath
curpath.mtime
curpath.directory?
curpath.to_s


The Ruby code just looks cleaner, more consistent – even though one could put parenthesis on all of these calls. ‘Pathname’ is obviously (or highly likely) to be a class. For the Path class proposed in Python PEP 355, one of the open issues in the PEP is this:





The name obviously has to be either “path” or “Path,” but where should it
live? In its own module or in os?





Let’s look at that first part again: The name obviously has to be either ‘path’ or ‘Path’. Either? Well, a lot of core Python classes and types are lower case – although many of them weren’t really types/classes until recently. I’m talking ‘str’, ‘object’, ‘file’ (aka ‘open’), etc. Some of this has to do with the history of the language and how it has grown / changed over the years. But obviously there’s more than one way to do it if you can’t really be sure of the proper way to capitalize it.




Indentation can be significant when scanning over code (not even reading into details). So can naming and other behaviors. Python programmers may see the ‘end’ keywords for Ruby’s blocks for for loops, if statements, etc, and go “ha! Python don’t need that line noise!”. But Ruby programmers may just as easily look at parenthesis on method calls that take no arguments and go “Ha! Ruby don’t need that line noise!” They may also look at things like ‘list.sort()’ and wonder why they don’t get a sorted copy of the list back (and may also wonder why it took until Python 2.4 for Python to finally grow an in-line ‘sorted copy’ function of its own). Ruby’s use of punctuation helps distinguish between the destructive (changes the object in question) and not destructive (returns a copy of the object in question):





Python:
>>> alist = [3,2,7,13,8]
>>> print alist.sort()
None
>>> alist
[2, 3, 7, 8, 13]
>>> alist = [3,2,7,13,8]
>>> print sorted(alist)
[2, 3, 7, 8, 13]
>>> alist
[3, 2, 7, 13, 8]

Ruby:
irb> alist = [3,2,7,13,8]
irb> p alist.sort
[2, 3, 7, 8, 13]
irb> alist
=> [3, 2, 7, 13, 8]
irb> p alist.sort!
[2, 3, 7, 8, 13]
irb> alist
=> [2, 3, 7, 8, 13]


Things like list.sort and having len(), sorted(), etc, being separate methods are things you get used to in Python. At the same time, it gives bad guidance for best practices (or just good practices) for writing code. If writing something like a Field object which can be bound to another object – should ‘bind(target)’ return a new copy of the Field bound to the target, or should it bind in place? In Ruby, one might write two methods, bind(target) and bind!(target), with the second one denoting that it changes the Field in place.




I don’t know how consistent other Ruby developers are in following that standard, but it’s great to have as an option. I also like the question mark used for boolean methods: alist.empty? alist.include? 7, and so on. Again – in my limited experience with Ruby, it’s been easier to understand a lot of the code I’ve seen:





popped = alist.pop if alist.respond_to? :pop
if popped.nil?
puts "Bastard didn't pop"
end

if hasattr(alist, 'pop'):
popped = alist.pop()
else:
print "Bastard couldn't pop"


The differences are negligible here, mostly a matter of preference. How about testing for emptiness? Not just testing for truth – but testing to see if a container is empty?





Ruby:
if alist.empty?
puts "It's Empty"
end

Python:
# truth testing
if not alist:
print "It's Empty"
# length testing
if len(alist) == 0:
print "It's Empty"

# Writing a custom 'empty' tester.
def empty(obj):
return (len(obj) == 0)

if empty(alist):
print "It's Empty"

# But 'empty' could also be destructive
def empty(obj):
obj[:] = []
return obj

if empty(alist):
print "will always be empty because this version of empty destroys"


More than one way to do it. Of course, the truth testing is the most commonly used in Python – but there are times when ‘emptiness’ and ‘truthiness’ have different meaning / impact. alist.empty? reads easy. The punctuation in the name differentiates it from a method like empty or empty! which might clear the object out (like ‘clear’ does in Ruby arrays). So this useful feature and convention makes it possible to look at an objects list of methods and pick out the queries.




So – am I saying Ruby is better than Python? No. Nor am I saying it the other way around. There are some very different designs here. But the enforced naming conventions and other small touches – constants versus variables, leading to consistent class and method spellings; punctuation in method names; ‘optional’ method call parenthesis causing one not to have to worry about whether they need to use object.id or object.id() – have enabled me to read large framework code like that in Rails or Hobix as easily or more easily than Python, even though Python claims to be written for readability and I’ve been programming in Python for a decade now and I’ve still scarcely used Ruby at all. There really seems to be a clean and simple elegance about it that I find myself yearning for.




The communities are interesting too. Python can’t even seem to settle on a good documentation tool. pydoc is way too simple in its HTML mode (but quite nice in the interpreter when you can do help(obj)). epydoc is quite comprehensive and supports comprehensive markup options, including the ability to document instance variables, method parameters, etc…, but its output can still be a bit hard to read.. Or at least, to differentiate the wheat from the chaff (I don’t think it’s epydoc’s fault, Python modules and objects may just be exposing too many extra objects that don’t always need to be documented and those get in the way of finding useful help). The almighty effbot has added PythonDoc to the mix as well. And there’s also Pudge. Zope 3 has its own API documentation tool with some specific knowledge of additional Zope 3 elements – sadly there’s no publically available online version to use for reference (yet).




And with all of these options – there’s nothing that quite matches the discoverability and usability of the Ruby on Rails API Docs. Again, I’ve gotten far better answers out of it than on any of the Python web tools I’ve evaluated… Ever. Which is why reading the source and being able to follow names is so important to me in Python. The source is often the best documentation you can easily get to and through. The Python standard library is very well documented. But beyond that, it’s often a lot of work. Ian Bicking wrote in his post Orthogonality is Pretentious (a post I generally disagree with – orthogonality leads to a pleasant predictability, I think, in languages like Smalltalk and also in Ruby) about PHP:





One example of this design in PHP is the lack of objects in the standard library. Instead it is one very long list of functions. If you want to do something with the standard library there either is a function for doing it, or there is not a function. If you want to see what you can do, you can just scan through the index.





And that’s what I like about Ruby on Rails. In the API Docs, one of the frames lists all of the methods in the system. That alone has been useful for just looking up functionality. One big list of functions (essentially), most of which are available where you need them most. Easy list to turn to and scroll through.




Similar functionality is in the WebHelpers library for Python – but there’s no version of the docs (at this time) that have that nice “big list of functions”. It’s click / try / click / try / click / try. At least it’s documented! But still, it just takes more time to weed out pertinent information.




Jumping to api.rubyonrails.org and scrolling through that bottom list to find ‘has_many’ again to find its options is a very quick process. (Just like most Python standard library lookups – the library and module indexed reference for Python is damn handy!)




Ugh. Where was I going with all of this? Nowhere really. I still like Python and it’s still my working programming language. But there are a lot of things about Ruby and what its community has been producing over recent years (beyond just Rails) that are increasingly enticing.


Baca Selengkapnya ....

Because I Could (SQLAlchemy, Zope 3, Metaclass Fun, Etc)

Posted by Unknown Jumat, 07 April 2006 0 komentar

I continue to be (generally) impressed by SQLAlchemy. After a couple of days worth of work, digging around the guts of Zope transactions and thread management along with SQLAlchemy’s guts of similar nature, I think I have a system in place that will work fine with Zope 3. Zope 3 uses a two phase commit transaction management system, whereas SQLAlchemy generally supports the basic ‘begin / commit / abort’ cycle. However, by taking advantage of SQLAlchemy’s nesting of transactions, I essentially have the following model in place:





  • Zope transaction begin—SQLAlchemy engine begin (starts a fresh outer scope and calls ‘begin’ on the database connection itself)

  • On Zope commit start (first phase of commit)—SQLAlchemy objectstore commit (sends changes managed in SQLAlchemy’s unit of work / object graph over the wire)

    • This is of interest because objectstore commit also calls engine.begin() and engine.commit(). SQLAlchemy is designed for ‘reentrance’, so that multiple calls to something like engine.begin() are OK – as long as they’re matched by an equal number of finishing calls like engine.commit(). When the nesting count is back to zero, engine.commit() saves.

    • In two phase commits, it’s allowable for an error to happen here. It’s probably not preferred, but it’s OK.



  • On Zope commit finish (final phase of commit)—SQLAlchemy engine commit. This ‘commit’ matches to the ‘begin’ at the start of the Zope transaction, and sends the ‘COMMIT’ statement to the target database.




Beyond that, I’m not doing too much work to track changes in either environment (SQLALchemy, ZODB) in this current setup. ZODB’s persistence manages the loading and unloading of its objects, and SQLAlchemy manages its own too. It’s not that I’m trying to mix them – it’s just that Zope really really really wants to run with the ZODB, so even if it’s not used, it’s probably going to be there.




If this system ends up actually doing its job, I’ll share the code. I’m trying to write it separate from the application I’m developing.




Also: for kicks, I’ve toyed with how I might get ActiveRecord style sytax (which I like) using Python and SQLAlchemy. This mostly works as it stands right now:





from ruts.storage.base import Base
from ruts.storage import act
import db.tables

class Venue(Base):
act.fromTable(db.tables.venues)

act.hasMany('Event', 'events', order_by='start_date')

class Presenter(Base):
act.fromTable(db.tables.presenters)

act.hasMany('Event', 'events', order_by='start_date')

class Event(Base):
act.fromTable(db.tables.events)

act.hasOne(Presenter)
act.hasOne(Venue)



>>> v = Venue.get(1)
>>> v.events
[<exmple.model.Event object at 0x104a930>]
>>> v.events[0].venue.title
'Testy McVenueVille'
>>> v.events.append(Event(title="Jackson"))
>>> v.commit()
>>> v.events
[<example.model.Event object at 0x104a930>, <example.model.Event object at 0x2b2c090>]
>>> e2 = Event.get(2)
>>> e = Event.get(1)
>>> from datetime import timedelta
>>> e2.start_date = e.start_date + timedelta(1)
>>> e2.end_date = e.end_date + timedelta(1)
>>> e.end_date
datetime.datetime(2006, 4, 8, 23, 0)
>>> e2.end_date
datetime.datetime(2006, 4, 9, 23, 0)
>>> v.events[1].end_date
datetime.datetime(2006, 4, 9, 23, 0)
>>> v.events[1].title
'Jackson'

Baca Selengkapnya ....

SQLAlchemy

Posted by Unknown Rabu, 05 April 2006 0 komentar

Among the short list of good (or at least, personally interesting) Python projects under development today stands SQLAlchemy. It’s a powerful toolkit for working with relational databases in Python, including doing object-relational mapping. It offers a lot more power and flexibility than SQLObject (Python) and ActiveRecord (Ruby), while still staying pretty close to those in relative ease of use (ie – no Hibernate style XML mappings).




Especially interesting is that SQLAlchemy is a SQL toolkit first, and O-R mapper second. It has a lot of support for query construction, compilation, native feature support, feature-agnostic support, pre-processing, post-processing, and more, that can also be used in the mapping layer. Already it seems like it’d be free of the kind of issues that I ran into when I tried to deal with a moderately complicated Inheritance / contained object scheme with Rails and ActiveRecord.


Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of apk zipalign.