Python Forum
a file-like class implementation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a file-like class implementation
#1
does anyone here have an actual working implementation of a file-like class, especially with support for write(), that they can share? based on stuff seen here and searching google this seems to be overly complicated (it seems that simply basing it on io.IOBase is not enough).
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
What kind of file do you need it to be like? If you are using a class, you wouldn't use write() because that writes to actual files. You'll surely have to make something specific to your needs. If you give your class a string variable or list, or a dictionary (or all or several of them) you can add or remove information from those. That's not complicated.
Reply
#3
it would be a method named "write" in the class to do whatever makes sense for this class. for example, it might simulate a write() operation by compressing the data and calling the write method of another file-like object. it could do any of a number of other things.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

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