Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Victor Subervi
Hi; I'm looking for something like os.environ['HTTP_REFERER'] but for python scripts. That is, if I have a script that is imported by another script, how can I have the script that is being imported determine which script imported it? TIA, Victor -- http://mail.python.org/mailman/listinfo/python

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Chris Rebert
On Sun, Dec 20, 2009 at 2:06 AM, Victor Subervi victorsube...@gmail.com wrote: Hi; I'm looking for something like os.environ['HTTP_REFERER'] but for python scripts. That is, if I have a script that is imported by another script, how can I have the script that is being imported determine which

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Victor Subervi
On Sun, Dec 20, 2009 at 5:18 AM, Chris Rebert c...@rebertia.com wrote: On Sun, Dec 20, 2009 at 2:06 AM, Victor Subervi victorsube...@gmail.com wrote: Hi; I'm looking for something like os.environ['HTTP_REFERER'] but for python scripts. That is, if I have a script that is imported

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread MRAB
Victor Subervi wrote: Hi; I'm looking for something like os.environ['HTTP_REFERER'] but for python scripts. That is, if I have a script that is imported by another script, how can I have the script that is being imported determine which script imported it? I don't know whether that's possible

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Stephen Hansen
On Sun, Dec 20, 2009 at 3:05 AM, Victor Subervi victorsube...@gmail.comwrote: 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

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Victor Subervi
On Sun, Dec 20, 2009 at 1:20 PM, Stephen Hansen apt.shan...@gmail.comwrote: On Sun, Dec 20, 2009 at 3:05 AM, Victor Subervi victorsube...@gmail.comwrote: 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

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Stephen Hansen
On Sun, Dec 20, 2009 at 11:01 AM, Victor Subervi victorsube...@gmail.comwrote: 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

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Tim Chase
Victor Subervi wrote: On Sun, Dec 20, 2009 at 1:20 PM, Stephen Hansen apt.shan...@gmail.comwrote: 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'

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Victor Subervi
On Sun, Dec 20, 2009 at 3:26 PM, Stephen Hansen apt.shan...@gmail.comwrote: On Sun, Dec 20, 2009 at 11:01 AM, Victor Subervi victorsube...@gmail.comwrote: 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.

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Dave Angel
Victor Subervi wrote: 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. V Amazing. When trying to split a path string,