Something Like os.environ['HTTP_REFERER']

Stephen Hansen apt.shansen at gmail.com
Sun Dec 20 13:20:16 EST 2009


On Sun, Dec 20, 2009 at 3:05 AM, Victor Subervi <victorsubervi at 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.

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.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091220/95beb1ff/attachment-0001.html>


More information about the Python-list mailing list