how to create file with spaces

Fredrik Lundh fredrik at pythonware.com
Thu Apr 6 06:36:18 EDT 2006


> try
>
>     filename = dirpath + "-dummy"
>     if not os.path.isfile(filename):
>         open(filename, "w").close()

better make that

    basename = os.path.basename(dirpath) + "-dummy"
    filename = os.path.join(dirpath, basename)
    if not os.path.isfile(filename):
        open(filename, "w").close()

</F>






More information about the Python-list mailing list