(fname, mode=0o666, dir_fd=None, **kwargs)
Touch a file. If it does not exist, create it.
Touch a file. If it does not exist, create it.
Touch a file . If it does not exist create it .
def touch(fname, mode=0o666, dir_fd=None, **kwargs):
    """Touch a file. If it does not exist, create it."""
    flags = os.O_CREAT | os.O_APPEND
    with os.fdopen(os.open(fname, flags=flags, mode=mode, dir_fd=dir_fd)) as f:
        os.utime(f.fileno() if os.utime in os.supports_fd else fname,
                 dir_fd=None if os.supports_fd else dir_fd, **kwargs)
def touch ( fname , mode = 0o666 , dir_fd = None , * * kwargs ) : flags = os . O_CREAT | os . O_APPEND with os . fdopen ( os . open ( fname , flags = flags , mode = mode , dir_fd = dir_fd ) ) as f : os . utime ( f . fileno ( ) if os . utime in os . supports_fd else fname , dir_fd = None if os . supports_fd else dir_fd , * * kwargs )