On Sun, Dec 20, 2009 at 3:26 PM, Stephen Hansen <apt.shan...@gmail.com>wrote:
> On Sun, Dec 20, 2009 at 11:01 AM, Victor Subervi > <victorsube...@gmail.com>wrote: > >> If you want a piece of code to have a variable number of differing >>> behaviors, that's something you can handle in many elegant ways. That's >>> something inheritance is good for, with a core default behavior represented >>> in one class and more specialized behavior represented in sub-classes. But >>> either way, you have to tell it which class to create at the moment, which >>> entails passing in a parameter explicitly activating one or the other. This >>> is a good thing. Don't try to get around it. >>> >> >> Inelegant. This will be elegant: >> >> ourFile = string.split(__file__, "/") >> p = ourFile[len(ourFile) - 1] >> p = p[: - 3] >> site = ourFile[4][:-10] >> if site != '': >> site = site[:-1] >> >> from this import that(site) >> >> Now it's automated. >> > > Since when is "automation" a synonym of "elegance"? > > Granted, elegance is something that will always be in the eye of the > beholder-- but looking at that chunk of code, I can't even figure out what > you're trying to do with it (or what that last 'from ...' line is even > supposed to mean). > <sigh> It's something to plug into any page anywhere and not have to worry about tweaking it for a given page. Not reading further responses to this post. V
-- http://mail.python.org/mailman/listinfo/python-list