Skip to content

Conversation

Thamirawaran
Copy link
Collaborator

@Thamirawaran Thamirawaran commented Oct 9, 2025

Description

with entry {
    name = "Thami";
    print(f"Hello {name}");
    print(F'Hello {name}');
    print(f"{{It is myname}}, name is: {name}");
    x= 10;
    y = 20;
    z = 65;
    b = "b";
    print(f"Sum of {x} and {y} is {x + y}");
    print(f"Debug: {b!a}");
    print(f"Hex: {y:x}");
    print(f"Binary: {x:b}");
    print(f"Value: {z:.2f}");
    print(f"Hex: {z:10}");
    name = "José";
    print(f"Default: {name}");
    print(f"ASCII: {name!a}");
    value = "Hello\nWorld";
    print(f"repr: {value!r}");
    print(f"str: {value!s}");
    print(f"ascii: {value!a}");
    print(f"name is {name} {f'inner: {name}'}");

}

Output
Hello Thami
Hello Thami
{It is myname}, name is: Thami
Sum of 10 and 20 is 30
Debug: 'b'
Hex: 14
Binary: 1010
Value: 65.00
Hex: 65
Default: José
ASCII: 'Jos\xe9'
repr: 'Hello\nWorld'
str: Hello
World
ascii: 'Hello\nWorld'
name is José inner: José

@Thamirawaran Thamirawaran linked an issue Oct 9, 2025 that may be closed by this pull request
@Thamirawaran
Copy link
Collaborator Author

Thamirawaran commented Oct 13, 2025

There is a bug in python

import ast
code = """
f"My name is {name}"
rf"My name is {name}"
"""
print(ast.dump(ast.parse(code), indent=4))
ast_obj = ast.parse(code)
print(ast.unparse(ast_obj))

output

Module(
    body=[
        Expr(
            value=JoinedStr(
                values=[
                    Constant(value='My name is '),
                    FormattedValue(
                        value=Name(id='name', ctx=Load()),
                        conversion=-1)])),
        Expr(
            value=JoinedStr(
                values=[
                    Constant(value='My name is '),
                    FormattedValue(
                        value=Name(id='name', ctx=Load()),
                        conversion=-1)]))],
    type_ignores=[])
f'My name is {name}'
f'My name is {name}'

Conclusion: based on python developers, ast will be equivalent for initial code and unparsed code.

@marsninja marsninja merged commit 98d7407 into main Oct 14, 2025
3 checks passed
@marsninja marsninja deleted the issue_2447 branch October 14, 2025 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] FString Critical

2 participants