File operations

aditya shukla adityashukla1983 at
Wed Sep 10 19:37:25 CEST 2008

Hello folks, I am using Python-2.5.2 on fedora 9 sulphur
-2.6.25-14.fc9.i686.I am creating a temporary file , in which data is
written by another program and then i am using that temporary file to do my
computations.I am new to linux and i am facing two issues

    homedir = os.path.expanduser('~')

    temp = tempfile.NamedTemporaryFile(
suffix='_suffix',prefix='prefix_',dir= homedir)


    tn =

    print tn

    Issue1 -> when i am logged in as root then everything works fine except
that the file is created in the current working directory
(/usr/Python-2.5.2) and not in the directory supplied as the dir='directory'
parameter.i have tried dir='/tmp' as well.i don't know how to fix this issue
and why the file is not getting created in the specified directory.

Issue2 -> when i am logged in as user ie any other user than root then i
get  this error

sh: prefix_u92XQJ_suffix: Permission denied
also , i cannot find the find in either the current working directory nor in
the dir='directory'.so i cant check the permission by using ls -l

Please help me understand this issue and eventually fix it.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list