splitext in write is not giving the basename
Question: I am trying to split text to the basename as:

    
    
    #!/usr/bin/python3
    import os.path 
    out.write(atoms[q]+" ")
    out.write(str(os.path.splitext(atoms[q][0]))+" ")
    

which is yielding:

    
    
    Mn7.pot ('M', '')  
    

where obviously the full text is `Mn7.pot` as shown by the first one, and by
splitext, I want the `'Mn7'`, (even better, if I can have without the
enclosing `''`).

If I do this in terminal, using print, I am getting the correct result(almost)
as:

    
    
     $python3
    Python 3.3.2 (default, Mar  5 2014, 08:21:05) 
    [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os.path
    >>> file="Mn7.pot"
    >>> os.path.splitext(file)
    ('Mn7', '.pot')
    

please show me how I can achieve this is `write` function as well.


Answer: If `atoms[q]` is `Mn7.pot` then `atoms[q][0]` is `M`.

You don't need the `str()` call and you don't need the `[0]`.

