Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
replacing the open function
#2
If import like that then it will overwrite build in open().
Output:
>>> print(open.__doc__[:115]) Open file and return a stream. Raise OSError upon failure. file is either a text or byte string giving the name ( >>> from os import close,open >>> print(open.__doc__[:115]) Open a file for low level IO. Returns a file descriptor (integer). If dir_fd is not None, it should be a file des
If ever want to use os.open()(never used it).
Then do not import like that,but use import os.
Doc Wrote:Note This function is intended for low-level I/O.
For normal usage, use the built-in function open(),
which returns a file object with read() and write() methods (and many more).
To wrap a file descriptor in a file object, use fdopen().
Reply


Messages In This Thread
replacing the open function - by Skaperen - Jan-26-2019, 02:41 AM
RE: replacing the open function - by snippsat - Jan-26-2019, 03:03 AM
RE: replacing the open function - by Skaperen - Jan-27-2019, 02:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  with open context inside of a recursive function billykid999 1 606 May-23-2023, 02:37 AM
Last Post: deanhystad
  How to Properly Open a Serial Port in a Function bill_z 2 4,566 Jul-22-2021, 12:54 PM
Last Post: bill_z
  What default directory does "open" function draw from? Athenaeum 4 3,859 Oct-07-2017, 06:15 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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