[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Temporary file
From: Dave Angel <davea () ieee ! org>
Date: 2009-04-10 4:43:38
Message-ID: 49DECE7A.1030507 () ieee ! org
[Download RAW message or body]
aditya shukla wrote:
> I am trying to create a temporary file.
>
> import tempfile
>
> temp = tempfile.NamedTemporaryFile(suffix='_suffix',
> prefix='prefix_',
> dir='/tmp',
> )
> try:
> print 'temp:', temp
> print 'temp.name:', temp.name
> finally:
> temp.close()
>
>
> But when i do ls /tmp or ls -a /tmp i cannot find the file or if i try
> to os.remove(temp.name) it shows a message that the file is not
> found.But print temp and print temp.name show
> temp: <open file '<fdopen>', mode 'w+b' at 0xb7e84800>
> temp.name: /home/swamp2/cacsgrad/axs9347/Desktop/prefix_zOfoX__suffix
>
>
>
> Please help me to fix it.
>
>
>
> Aditya
>
>
According to the docs for NamedTemporaryFile(), the file will be deleted
when closed (unless you specify otherwise with delete=False)
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic