Example 1 (works as expected)
file = open("D:\Programming\Python\working_with_files\cities.txt",
'r+') ## contains list cities
# the following code adds new record to the beginning of the file,
expected behaviour
file.write("new city\n")
file.close()
Example 2 (weird behaviour)
file = open("D:
Apologies!
It seems that I added python-comitters and python-announce but forgot to
add python-dev. Here is the email to python-announce:
[1]Mailman 3 [RELEASE]
Python 3.11.2, Python
3.10.10 and 3.12.0 alpha 5
are available - [2]favicon.ico
Python-announce-list
Looks like the data to be written is buffered, so actual write takes
place after readlines(), when close() flushes buffers.
See io package documentation, BufferedIOBase.
The solution is file.flush() after file.write()
Can't deny, such a behaviour looks utterly weird. Try to avoid designing
yo
On 2023-02-19 16:57:02 +, Axy via Python-list wrote:
> Looks like the data to be written is buffered, so actual write takes place
> after readlines(), when close() flushes buffers.
>
> See io package documentation, BufferedIOBase.
>
> The solution is file.flush() after file.write()
Or altern
On 2023-02-19 14:03, Azizbek Khamdamov wrote:
Example 1 (works as expected)
file = open("D:\Programming\Python\working_with_files\cities.txt",
'r+') ## contains list cities
# the following code adds new record to the beginning of the file,
expected behaviour
file.write("new city\n")
file.close(
On 2/19/2023 11:57 AM, Axy via Python-list wrote:
Looks like the data to be written is buffered, so actual write takes
place after readlines(), when close() flushes buffers.
See io package documentation, BufferedIOBase.
The solution is file.flush() after file.write()
Another possibility, fro
On Mon, 20 Feb 2023 at 03:41, Azizbek Khamdamov
wrote:
>
> Example 1 (works as expected)
>
> file = open("D:\Programming\Python\working_with_files\cities.txt",
> 'r+') ## contains list cities
Side note: You happened to get lucky with P, w, and c, but for the
future, I recommend using forward slas
On 2/19/2023 1:53 PM, Chris Angelico wrote:
On Mon, 20 Feb 2023 at 03:41, Azizbek Khamdamov
wrote:
Example 1 (works as expected)
file = open("D:\Programming\Python\working_with_files\cities.txt",
'r+') ## contains list cities
Side note: You happened to get lucky with P, w, and c, but for th
On 2023-02-19 12:59:43 -0500, Thomas Passin wrote:
> On 2/19/2023 11:57 AM, Axy via Python-list wrote:
> > Looks like the data to be written is buffered, so actual write takes
> > place after readlines(), when close() flushes buffers.
> >
> > See io package documentation, BufferedIOBase.
> >
> >
On Mon, 20 Feb 2023 at 06:24, Thomas Passin wrote:
>
> On 2/19/2023 1:53 PM, Chris Angelico wrote:
> > On Mon, 20 Feb 2023 at 03:41, Azizbek Khamdamov
> > wrote:
> >>
> >> Example 1 (works as expected)
> >>
> >> file = open("D:\Programming\Python\working_with_files\cities.txt",
> >> 'r+') ## cont
On 2023-02-19 19:31, Chris Angelico wrote:
On Mon, 20 Feb 2023 at 06:24, Thomas Passin wrote:
On 2/19/2023 1:53 PM, Chris Angelico wrote:
> On Mon, 20 Feb 2023 at 03:41, Azizbek Khamdamov
> wrote:
>>
>> Example 1 (works as expected)
>>
>> file = open("D:\Programming\Python\working_with_files\
On 2/19/2023 2:31 PM, Chris Angelico wrote:
On Mon, 20 Feb 2023 at 06:24, Thomas Passin wrote:
On 2/19/2023 1:53 PM, Chris Angelico wrote:
On Mon, 20 Feb 2023 at 03:41, Azizbek Khamdamov
wrote:
Example 1 (works as expected)
file = open("D:\Programming\Python\working_with_files\cities.txt"
Azizbek Khamdamov wrote at 2023-2-19 19:03 +0500:
> ...
>Example 2 (weird behaviour)
>
>file = open("D:\Programming\Python\working_with_files\cities.txt",
>'r+') ## contains list cities
># the following code DOES NOT add new record TO THE BEGINNING of the
>file IF FOLLOWED BY readline() and readlin
On 2/19/23 14:06, Dieter Maurer wrote:
Azizbek Khamdamov wrote at 2023-2-19 19:03 +0500:
...
Example 2 (weird behaviour)
file = open("D:\Programming\Python\working_with_files\cities.txt",
'r+') ## contains list cities
# the following code DOES NOT add new record TO THE BEGINNING of the
file IF
On 2/19/2023 6:10 PM, Mats Wichmann wrote:
On 2/19/23 14:06, Dieter Maurer wrote:
Azizbek Khamdamov wrote at 2023-2-19 19:03 +0500:
...
Example 2 (weird behaviour)
file = open("D:\Programming\Python\working_with_files\cities.txt",
'r+') ## contains list cities
# the following code DOES NOT add
15 matches
Mail list logo