Python Forum
creating a dummy file object
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
creating a dummy file object
#1
i want to create a file object that any attempt to write just drops the data, never calling the system, and any attempt to read gets no data and simulates an end of file, never calling the system, working like "/dev/null" does on Unix/Linux. is an object with functions read() and write() doing the appropriate things and a dummy close() sufficient?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
It may suffice in many cases, however if you want a more robust implementation, you could subclass the abstract base classes of module io and implement their stub methods instead.
Skaperen likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  creating an unlinked invisible file, writing it, then linking it Skaperen 2 1,301 Feb-21-2023, 05:40 PM
Last Post: Skaperen
  creating my own file-like object Skaperen 0 1,186 Feb-06-2022, 08:25 PM
Last Post: Skaperen
  i want to create my own file-like object Skaperen 0 2,067 Apr-17-2020, 11:47 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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