Calling all Python experts

Michael Hipp Michael
Wed Dec 20 07:22:59 PST 2006


David Bandel wrote:
> Folks,
> 
> OK, well, someone took a perfectly good idea originally coded in Perl
> and decided he liked Python better :-(.
> 
> Well, I need to try to figure out how Python handles grabbing
> arguments to programs.  Specifically, sendmail is calling procmail,
> which runs a filter in Python (if only this were Perl I could fix it,
> but I don't feel like learning enough Python to translate the entire
> program to Perl).
> 
> The install suggests something like:
> "/var/mail/%s" % os.environ.get("USER")

Did a bit more reading on the 'os' module. Turns out this syntax is probably 
more "correct" and a bit simpler too:

   os.environ['USER']

Note that the environ is parsed once when Python is started. See:

   http://docs.python.org/lib/os-procinfo.html

Michael



More information about the Linux-users mailing list