Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does p stand for in "fp" of with open(filename, "w") as fp:

Tags:

python

It might be extremely frivolous, but google searches are not helpful indeed.

In python official docs, it constantly refers file as fp:

with open(filename, "w") as fp:
fp.write() 

What's does "p" stand for?

like image 449
AbstProcDo Avatar asked Aug 21 '18 06:08

AbstProcDo


People also ask

Which of the following is default mode for file opening a w/b r/c a/d w+?

r. Opens a file for reading only. The file pointer is placed at the beginning of the file. This is the default mode.

What is a file pointer in Python?

The file pointer is at the end of the file if the file exists. The file opens in the append mode. If the file does not exist, it creates a new file for reading and writing.

What does fp mean in C++?

In your line of code, fp means "file pointer". In the C standard library, for example when using the fopen function to open a file, a FILE pointer is returned. FILE is a kind of structure that holds information about the file.


1 Answers

"fp" stands for "file pointer" and it was a pointer to a FILE structure in C. The name "fp" just sort of stuck.

"fd" was an alternate ad usually indicated an unsigned integer, which was the offset of the referenced file in the "file table" (file descriptor).

like image 193
LSerni Avatar answered Oct 02 '22 17:10

LSerni