Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
methods for open files
#1
i am looking for the documentation of all methods (and attributes, if any) of open file objects. i want to see what all is available, and, of course, details of usage.

in the general case, many functions return objects that have methods and/or attributes. ehen it is a function in a module, usually the documentation for the module includes the documentation for objects returned by its functions (i have seen cases where this is apparently not true). is there a typical place to find such documentation for built-in functions?
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
You can read the documentation of module io
Reply
#3
Something like that:
In [1]: with open('39768.txt', 'r') as f:
    ...:     for method in dir(f):
    ...:         print(method, '\n'*2, method.__doc__, '\n'*2, '#'*40, '\n')
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
so if i create a class with all those methods and attributes working in a like way, or an appropriate subset for what i am doing, i'll have fake files and fake i/o?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
Often one only needs a small subset of these methods to create usable file-like objects, because functions that take a file parameter typically use a small part of the file API. For example a function that outputs XML data may take a file like object as paramater and use only its write() method. The function can be called with any object having a write method.
Reply
#6
did we get an introduction from Gribouillis? he/she seems to be an experienced pythonista. i'm curious how much and what experience overall.
Tradition is peer pressure from dead people

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


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Right way to open files with different encodings? Winfried 2 168 Yesterday, 05:50 PM
Last Post: snippsat
  Open files in an existing window instead of new Kostov 2 301 Apr-13-2024, 07:22 AM
Last Post: Kostov
  Class test : good way to split methods into several files paul18fr 4 485 Jan-30-2024, 11:46 AM
Last Post: Pedroski55
  open python files in other drive akbarza 1 691 Aug-24-2023, 01:23 PM
Last Post: deanhystad
  How to open/load image .tiff files > 2 GB ? hobbyist 1 2,455 Aug-19-2021, 12:50 AM
Last Post: Larz60+
  Open and read multiple text files and match words kozaizsvemira 3 6,752 Jul-07-2021, 11:27 AM
Last Post: Larz60+
Question (solved) open multiple libre office files in libre office lucky67 5 3,329 May-29-2021, 04:54 PM
Last Post: lucky67
  Can't open files Lass86 5 2,441 Nov-10-2020, 07:18 PM
Last Post: jefsummers
  Using Python to loop csv files to open them Secret 4 2,729 Sep-13-2020, 11:30 AM
Last Post: Askic
  Find specific subdir, open files and find specific lines that are missing from a file tester_V 8 3,585 Aug-25-2020, 01:52 AM
Last Post: tester_V

Forum Jump:

User Panel Messages

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