Why when my python code writes files, it seems case-insensitive?

262 views Asked by At

I have a dictionary and want to write the values to files whose names are based on the keys. My keys can be very similar, a letter can be upper or lower case.

dict_1 = {'g.XXXXX': '>g|XXXXX|1\nSRGSSAGFDRHITIFSPEGRLYQVEYAFKAINQGGLTSVAVRGKDCA',  'G.XXXXX': '>G|XXXXX|1\nSAGFDRHITIFSPEGRLYQVEYAFKAINQGGLTSVAVRGKDCAVIVTQKKVPDKLLDSSTVTHL'}

for k in dict_1:
    with open(f'{k}.data.txt', 'w') as out:
    out.write(f'{dict_1[k]}\n')

The script writes only 'g.XXXXX.data.txt' but with the data of the 'G.XXXXX' key, instead of both files 'g.XXXXX.data.txt' and 'G.XXXXX.data.txt', whith their respective data

Why and how can I fix this? Thanks!

1

There are 1 answers

0
sfgroups On

It runs twice, in windows its overwriting the file. it creates two files in Linux.

PS C:\work> python a.py
g.XXXXX
G.XXXXX