Python Forum
module 'os' has no attribute 'tmpfile'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
module 'os' has no attribute 'tmpfile'
#1
Hello, I wrote the following program and tried to execute it:
#!/usr/bin/python3.8
import os
# The file has no directory entries associated with it and will be
# deleted automatically once there are no file descriptors.
tmpfile = os.tmpfile()
tmpfile.write('Temporary newfile is here......')
tmpfile.seek(0)

print (tmpfile.read())
tmpfile.close
but I'm getting an error:
Error:
Traceback (most recent call last): File "/home/user/Desktop/Programming/Python/Os tmpfile method.py", line 5, in <module> tmpfile = os.tmpfile() AttributeError: module 'os' has no attribute 'tmpfile'
Reply
#2
I could be wrong but, the error is saying the os has no method called tmpfile
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
probably you want to look at tempfile module
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
#4
Why did you think there was a tmpfile function in the os module?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 719 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  Module 'time' has no attribute 'clock' Sophie 4 3,033 Jan-25-2022, 08:05 PM
Last Post: Sophie
  AttributeError: module 'string' has no attribute 'uppercase' Anldra12 10 10,111 Apr-23-2021, 05:30 PM
Last Post: ibreeden
  AttributeError: module 'collections' has no attribute 'namedtuple' epgs1975 2 10,241 May-04-2020, 08:10 PM
Last Post: epgs1975
  AttributeError: module 'platform' has no attribute 'python_implementation' davidpluseipi 3 4,677 May-01-2020, 11:47 PM
Last Post: Larz60+
  AttributeError: module 'asyncio' has no attribute 'get_event_loop Susmitha 5 20,078 Sep-03-2019, 02:33 AM
Last Post: chengonghao
  Plotly error - AttributeError: module 'plotly.plotly' has no attribute 'iplot' fernando_santos 0 5,558 Jul-24-2019, 02:35 PM
Last Post: fernando_santos
  Please help me error "AttributeError: 'module' object has no attribute 'ElementTree'" mattroi261192 4 6,918 Nov-11-2018, 05:01 AM
Last Post: mattroi261192
  'module' object has no attribute 'utilities' art3mis 1 3,438 Nov-04-2018, 12:54 AM
Last Post: Larz60+
  AttributeError: module 'csv' has no attribute 'reader' python1234 2 26,777 Jun-08-2018, 06:13 AM
Last Post: python1234

Forum Jump:

User Panel Messages

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