I am working through a tutorial on searching an .html file using regular expressions (the re module). I am using the interpreter.
I opened the file and preformed my search. After each attempt, I used f.seek(0) to return to the beginning of the file for the next attempt. I confirmed my location in the file using f.tell().
The first few time that I did this, the location of the file (in bytes) was returned without an L appended to it. But after several attempts, f.tell() returned the location with an L appended.
I understand that the L signifies that the file location (in bytes) is a long number. But why would f.tell() suddenly begin to return the L, when it had not on prior occasions?
I then closed and re-opened the file, and f.tell() returned the long number from the onset?
Yes, the
Lsignifies along(which is practically only limited by the memory and computation time).Python in general does automatic promotions of
ints tolongs as soon as the value exceeds the range theinttype can handle. Also, if some operation with anotherlongtakes place, the result always is along(0 + 0L→0L).In your case I can only speculate what caused this effect. Maybe reading beyond a certain limit caused the promotion, maybe some internal handling (which does not always take place) was the reason.
I don’t think that it will matter to you.