Skip to content

f-string evaluation of conditional expressions with != operator seems to fail #129093

@JD-Veiga

Description

@JD-Veiga

Bug report

Bug description:

Hi,

I really feel puzzled by this behaviour:

>>> print(f'{True == True=}')
True == True=True
>>> print(f'{True != True=}')
True False

I expected that the output of print(f'{True != True=}') would be True != True=False.

According to docs, "[t]o display both the expression text and its value after evaluation, (useful in debugging), an equal sign '=' may be added after the expression". So print(f'{True != True=}') fails because the expression text is not fully displayed -- even "=" is omitted.

Sorry if this is a duplicate -- I was not able to find any other report here and in Cython issue tracker.

Thank you.

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions