Change in Python 3.3 with the treatment of sys.argv
Colin J. Williams
cjw at ncf.ca
Sat Mar 23 13:27:28 CET 2013
On 22/03/2013 6:11 PM, Ethan Furman wrote:
> On 03/22/2013 02:57 PM, Colin J. Williams wrote:
>> Below is an extract from some code to run on Python 2.7.3, 3.2.3 and
>> 3.3.0 to compare speeds, both between versions and
>> if __name__ == '__main__':
>> # Text string for initial test - Modify for your own machine or
>> # delete it and and answer the input statement with your own machine
>> # characteristics.
>> sys.argv[1:]= ('Intel Pentium D CPU 3.0GHz 1.99 GB of RAM 221GB
>> Disk Free space', )
>> def main():
>> if len(sys.argv) > 1:
>> idMachine= ' '.join(sys.argv[1:])
>> oFile= open('FP' + now + '.log', 'w')
>> oFile.writelines(idM + '\n' + sys.version + '\n')
>> For 2.7, the result is:
>> 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
>> for 3.2, the result is:
>> 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)]
>> For 3.3, the result is:
>> 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit
>> The full test result, for random matrices of increasing order is
> First, this is what I get with 3.3:
> Python 3.3.0 (default, Sep 29 2012, 17:14:58)
> [GCC 4.7.2] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> --> import sys
> --> sys.argv
> --> sys.argv[1:] = ('this is a test!', )
> --> sys.argv
> ['', 'this is a test!']
> --> ' '.join(sys.argv[1:])
> 'this is a test!'
> Second, your code doesn't show being joined by an underscore.
APOLOGIES to those who responded.
It seems that a change was made in the program between the 3.3 run and
the other runs.
Each produces the same heading now.
Yes, I should have posted the test code. But, in these circumstances,
there is no point in doing that.
More information about the Python-list