Jose' Matos wrote:
>> red   = float(atoi(hexcolor[0:2], 16)) / 255.0
>> green = float(atoi(hexcolor[2:4], 16)) / 255.0
>> blue  = float(atoi(hexcolor[4:6], 16)) / 255.0
> 
> This is correct but unnecessary, either
> float(atoi(hexcolor[0:2], 16)) / 255
> or
> atoi(hexcolor[0:2], 16) / 255.0
> 
> would be enough.

Sure. But being explicit doesn't hurt.

>> def run_command(prog_name, prog_call):
>> pid = os.fork()
>> if pid == 0:
>> os.execvp(prog_name, prog_call)
>> print "%s failed", prog_name
>> os.exit(1)
>> pid, exit_status = os.waitpid(pid, 0)
>> return exit_status == 0
> 
>   Here we don't need the execv series as we know the number of
> arguments. And if we now the path then we don't need also the p
> family, so in this case os.execl should be enough.

Mine neither (despite appearences). However, why would I
want to list the args explicitly:
        execl(path, arg0, arg1, ...)
        execv(path, args)
A list is *much* easier to manipulate. 

Consider the following (used by lyxpreview2ppm.py)

    gs_call = [gs, "-q", "-dNOPAUSE", "-dBATCH", "-dSAFER", \
               "-sDEVICE=pnmraw", \
               "-sOutputFile=%s" % ppm_files, \
               "-dGraphicsAlphaBit=%s" % alpha, \
               "-dTextAlphaBits=%s" % alpha, \
               "-r%s" % resolution, \
               ps_file]

> Other than this I say that you are starting to master python. :-)

Hmphhh. Hardly.

> I have used the documentation available in:
> http://www.python.org/doc/
> 
> My main reference is usualy the "Library Reference".

Yes, I've found that. I also find it's easier to search than the
"snake" book or whatever it's called ("Programming Python").

-- 
Angus

Reply via email to