How does opening file work | Sololearn: Learn to code for FREE!

+10

How does opening file work

Ofcuruse it's not necessary open it could be any function that opens file like fstream in c++ etcI was wondering how the open() function in python works on the operating system like how does it read a file not the code but what happeneds in the computer

9/6/2019 8:07:24 PM

Cout

21 Answers

New Answer

+18

Python is implemented with C, or a C based language. If you want to understand how Python opens a file, you should start your investigation with how C opens a file, how a system call works, etc.

+13

C++ is also a C based language, as is Java (jpython), hence why I said it's useful to first look at how C handles file I/O. The practice is generally shared across the entire family of C based languages

+9

Cout This should be helpful in understanding the fundamentals of file I/O at the system level: https://www.geeksforgeeks.org/input-output-system-calls-c-create-open-close-read-write/

+5

Cout, you're here *asking* for something. You don't have to be happy with an answer, but complaining and downvoting the first guy giving you *something* is dubious style. There is something called 'tone'. At the very least, the effect will be that other people hesitate to give you their answer.

+5

Cout am sure if you have done better Googling you won't say sh*t about does who are trying to help you out on your quest for knowledge, because this is actually not a problem to be solve that someone can actually help you on, its a quest you actually need to work for, atleast appreciate there effort and they will definitely find more for you, as Core have said earlier "no better place than the documentation itself" no one is an island of knowledge

+4

Not sure if these are helpful. https://www.quora.com/In-programming-why-must-we-open-a-file-before-we-can-use-it https://www.guru99.com/reading-and-writing-files-in-python.html

+3

Cout, there are friendly ways to say that an answer doesn't help you to solve your problem. If people get the impression that you're being a jerk, they'll likely lose interest in helping you, simple as that.

+3

Well. Python calls OS specific API to open a file. OS calls the driver, depending on the disk type, the driver calls the firmware of the device, the firmware does his unique and specific hardware control to gather a single byte and return it to the driver.

+2

https://code.sololearn.com/cGbrpvGbk8Pn/?ref=app You can see also: https://www.w3schools.com/python/python_file_handling.asp

+2

MIT app inventor is easiest check on web

+1

no better place than the documentation itself, https://docs.python.org/3/library/functions.html

+1

literally I sent you the documentation for every built in function currently in python, if you were to go on the website there is a clear description on what open() does/is. If you need further instructions on how to navigate the website I’d be more than happy, if not you could always look up a tutorial.

+1

Ace you are right sorry for that and it's not just python it's also c++ and even notepad

0

Core dude you sent me a list of functions that's not what I asked for

0

Core you misunderstood the question I asked what it does in the computer in the os not how to use it

0

Cout locates a file and opens it, returns a file object. I/O, parameters sets restrictions/permissions.

0

Cout Python is open source, this is as “complex” as it gets. https://github.com/python/cpython/blob/master/Lib/_pyio.py

0

What is the making of a great programmer? Is it being a coder or developer or winning many simple challenges?

0

-1

HonFu Man you are talking nonsense if someone gives me an answer that gives me nothing also if he answered doesn't metter if you don't know the answer don't answer why is it metter that if someone knows the answer he won't answer I know for me I couldn't care less