Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Temp folder creation
#8
tempfile module is available in python 2.7. However tempfile.TemporaryFolder() was introduced in 3.2 That is why you get error there, not earlier when you use tempfile.TemporaryFile().
Few points - you use tempfile.TemporaryFile() to create the file. Note that it will be destroyed immediately when you close it. I think you want to use tempfile.mkstemp() in which case YOU are responsible to delete it after. By default temporary file it is created in the default temp folder for the current OS. In 2.7 you have also tempfile.mkdtemp() which creates temporary directory and again you are responsible to delete it. In short, I think you need to use mkstemp() and possibly mkdtemp(), not the objects directly.
Finally, you should move to python3 as python2 support ends 1 Jan 2020.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Temp folder creation - by ste1605 - Oct-02-2018, 02:29 PM
RE: Temp folder creation - by micseydel - Oct-02-2018, 04:21 PM
RE: Temp folder creation - by ste1605 - Oct-02-2018, 04:32 PM
RE: Temp folder creation - by buran - Oct-02-2018, 06:00 PM
RE: Temp folder creation - by ste1605 - Oct-03-2018, 08:20 AM
RE: Temp folder creation - by buran - Oct-03-2018, 09:41 AM
RE: Temp folder creation - by ste1605 - Oct-03-2018, 09:53 AM
RE: Temp folder creation - by buran - Oct-03-2018, 10:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Deleting Windows temp folder Raysz 7 605 Apr-02-2024, 12:36 PM
Last Post: Raysz
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 649 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,612 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  pyspark creating temp files in /tmp folder aliyesami 1 5,187 Oct-16-2021, 05:15 PM
Last Post: aliyesami
  Help with storing temp data for each day then recording min/max in app. trthskr4 3 2,484 Sep-10-2021, 10:51 PM
Last Post: trthskr4
  How to save Matplot chart to temp file? Morkus 2 4,629 Jun-12-2021, 10:52 AM
Last Post: Morkus
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,534 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  Python Cut/Copy paste file from folder to another folder rdDrp 4 5,194 Aug-19-2020, 12:40 PM
Last Post: rdDrp
  Get system info from PI (cpu load and temp) korenron 2 2,146 Aug-04-2019, 08:45 AM
Last Post: korenron
  folder PyQt5 created during creation exe atlass218 0 1,585 Apr-26-2019, 06:25 PM
Last Post: atlass218

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020