Skip to content

Implement % string/bytes formatting #403

Closed

Description

@pfalcon

While I personally prefer %-style string formatting, I refrained from trying to implement it, because having both str.format and str % tuple seemed like redundancy for small Python implementation but:

  1. http://legacy.python.org/dev/peps/pep-0461/ reinforces %-formatting as active, supported Python feature, which once again offers more functionality than str.format.
  2. There's existing code which uses %, so if we want to run it, we need to support % (I hit that when trying to run tests from CPython testsuite - rewriting them besides being monkey job leads to inability to report that we're able to run unmodifed CPython testsuite).

Activity

  1. dhylands commented on Mar 31, 2014

    @dhylands
    Contributor

    I can take a look at this. I've been working on str.format and have a fairly complete implementation. I'm just testing the floating point stuff now.

    I wound up refactoring a bunch of the low-level pfenv functions from printf.

  2. pfalcon commented on Mar 31, 2014

    @pfalcon
    ContributorAuthor

    Why it's not in the mainline then? ;-) And yes, is you're on this topic, please go for it, but it would be nice to have basic implementation (%s/%r) soon, and then work on elaborating it.

  3. dhylands commented on Mar 31, 2014

    @dhylands
    Contributor

    Why it's not in the mainline then? ;-) And yes, is you're on this topic, please go for it, but it would be nice to have basic implementation (%s/%r) soon, and then work on elaborating it.

    It's not on mainline yet because I haven't finished coding it :)

    As soon as its all working and passing tests, then I'll be doing a pull request for the str.format stuff, which should be within a couple of days. Right now, it implements everything but the comma modifier, and I'm just hooking up the floating point stuff. I'll defer the comma operator for a later merge request.

    If you want to do the very basic support for % (perhaps with just strings), I can take that and hook in the rest.

  4. pfalcon commented on Mar 31, 2014

    @pfalcon
    ContributorAuthor

    Sounds good, pushed as 4db727a

  5. dpgeorge commented on Apr 5, 2014

    @dpgeorge
    Member

    I think this has been implemented, thanks @dhylands!

  6. added a commit that references this issue on Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, new feature implementations

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions