Python Forum
semantics of open(buffering=-1) ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
semantics of open(buffering=-1) ?
#1
the library reference manual shows for open() that the keyword argument buffering= has a default value of -1. it does not explain what that means or does. is it a default indicator like None usually is?
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
The docs do say what happens when no value is passed for buffering, i.e. what the default behaviour is (which is what -1 corresponds to). The great thing about Python being open source is that you can go look at the source - it is left as an exercise for you to find the source for open and see what it does with that argument.
Reply
#3
then, what is the point of there being that document if the source can be used? i think Python would not be as popular as it is if everyone needed to read the source to know how it all worked? source is good, but not for this.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
Well the docs do tell you what the default behaviour is and that buffering should be an integer, which is really about as much as you need to know as a user. If you actually care why the default is -1 instead of None then yeah, you can look at the source to see what it's doing.
Reply
#5
back when i coded in C, -1 was often used as "assume nothing" value, even where i could have done that with 0. getting an answer to "why?" probably does need to go to source. a useful document would be "Python Tricks and Hints". it would tell programs a lot of ways to make things work, including telling when using -1 or -1.0 works out better than None. i'm curious, but not urgently so. i'll probably look at the source next year.
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