Skip to content

Feedback on lowercase \U, \u, \x escapes introduced in 23.1 preview style #2916 #3568

@yilei

Description

@yilei

I'm not sure if lowercase is the better decision, so I'm filing this feedback for discussion.

Reasons to favor lowercase:

  1. repr() uses lowercases:

    >>> "\x1B"
    '\x1b'
    >>> "\u200B"
    '\u200b'
    >>> "\U0001F977"
    '\U0001f977'
  2. I sampled 500K files from our codebase, lowercase is bit more popular (the count below is the total number escape sequences in strings):

    \x escapes:

    • lowercase: 440K
    • uppercase: 351K
    • no letters: 341K

    \u escapes:

    • lowercase: 144K
    • uppercase: 49K
    • no letters: 46K

    (This might actually be a reason to not have a preference, since this is polarized.)

Reasons to favor uppercase:

  1. For \x escapes, Black already uses uppercase for hex numbers: 0xEF, so this will be consistent with Black itself.
  2. For unicodes, https://unicode.org/ uses uppercases.

I personally think the uppercase reasons are stronger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.T: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions