I need help debugging some odd file behavior in Python. Take the following script (write_con.py):
f=open('con.txt','w')
f.write('hi')
In Linux, this creates a file called con.txt with the contents hi. In Windows this writes hi to the console and does not create a file. I've tried this with Python 2.5.1, 2.6.3, 2.6.5, and 2.7.2. Example run:
C:\Users\rpsharp> C:\Python27\python.exe .\write_con.py
hiC:\Users\rpsharp> C:\Python25\python.exe .\write_con.py
hiC:\Users\rpsharp>
Yet a file named anything other than something that starts with con works fine (write_other_con.py):
f=open('other_con.txt','w')
f.write('hi')
Here's a run:
C:\Users\rpsharp> C:\Python25\python.exe .\write_other_con.py
C:\Users\rpsharp> type .\other_con.txt
hi
What's going on that causes windows versions of python to write to the console when the prefix of the named file is con?