Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

file.seek(file.tell()) needed: bad docs or a bug? #93079

Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-IOtype-bugAn unexpected behavior, bug, or error
@Akuli

Description

@Akuli

The following produces a file containingb'hello\n ', i.e.hello followed by a newline and a space:

withopen("asd.txt","w")asfile:file.write("hello\n")withopen("asd.txt","r+")asfile:file.read(4)file.write(" ")

But if I addfile.seek(file.tell()), then it instead producesb'hell \n' as I would expect:

withopen("asd.txt","w")asfile:file.write("hello\n")withopen("asd.txt","r+")asfile:file.read(4)file.seek(file.tell())file.write(" ")

Is this correct behaviour? I can't find any mention of it in the docs. (I can't usefile.seek(4) because that "produces undefined behaviour" according to docs.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-IOtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp