On 22/07/11 14:30, Frank Millman wrote:
> This is what I get after modifying timeit.py as follows -
> 
>     if args is None:
>         args = sys.argv[1:]
> +       print(args)
> 
> C:\>python -m timeit int(float('165.0'))
> ["int(float('165.0'))"]
> 100000 loops, best of 3: 3.43 usec per loop
> 
> C:\>python -m timeit int(float("165.0"))
> ['int(float(165.0))']
> 1000000 loops, best of 3: 1.97 usec per loop
> 
> C:\>python -m timeit "int(float('165.0'))"
> ["int(float('165.0'))"]
> 100000 loops, best of 3: 3.45 usec per loop
> 
> It seems that the lesson is -
> 
> 1. Use double-quotes around the command itself - may not be necessary
> if the command does not contain spaces.
> 2. Use single-quotes for any literals in the command.

What about 'int(float("165.0"))' (single quotes around the argument)?
Does that pass the single quotes around the argument to Python? Or does
it eliminate all quotes?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to