Victor Subervi wrote:
On Sun, Dec 20, 2009 at 1:20 PM, Stephen Hansen <apt.shan...@gmail.com>wrote:
Of course, I can pass the page name as a parameter, but that's not
elegant.

That is precisely what it is in fact-- elegant; it is non-elegant to have
magical behavior where what 'imports' something somehow changes or
determines how that something behaves.

It may be possible to go into dark places to discover what code first
imported a module, but its not possible to discover what code does
subsequent imports-- and in either case, this is /not/ something that has
any sort of elegance to it. Its deeply hackish.

Inelegant. This will be elegant:

[snipped atrocious malformed code that won't compile, has undocumented magic constants, and is fragilely dependent on a certain directory/naming convention]

For your claims to be a right-brained artistic type, your evidenced sense of aesthetic leans towards the baroquen. Trust the list's suggestions -- your proposed code is NOT elegant. This is reinforced on multiple fronts: Stephen and MRAB have already commented this is an inelegant idea (and Chris hinted that it's undesirable) and I share their opinion; additionally, the fact that Python doesn't make this easy suggests that it's not the preferred way to do things. Yes, one can sniff stacks, check the system module cache before and after an import, or do other crazy black magic, but for your described use-case, proper architecture can be both elegant and simple as Stephen suggests.

-tkc




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to