Skip to content

Implement % string/bytes formatting #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pfalcon opened this issue Mar 31, 2014 · 5 comments
Closed

Implement % string/bytes formatting #403

pfalcon opened this issue Mar 31, 2014 · 5 comments
Labels
enhancement Feature requests, new feature implementations

Comments

@pfalcon
Copy link
Contributor

pfalcon commented Mar 31, 2014

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).
@dhylands
Copy link
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.

@pfalcon
Copy link
Contributor Author

pfalcon commented Mar 31, 2014

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.

@dhylands
Copy link
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.

@pfalcon
Copy link
Contributor Author

pfalcon commented Mar 31, 2014

Sounds good, pushed as 4db727a

@dpgeorge
Copy link
Member

dpgeorge commented Apr 5, 2014

I think this has been implemented, thanks @dhylands!

@dpgeorge dpgeorge closed this as completed Apr 5, 2014
tannewt pushed a commit to tannewt/circuitpython that referenced this issue Nov 3, 2017
atmel-samd: Fix SAMD51 SWCLK reset so we can connect the JLink
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests, new feature implementations
Projects
None yet
Development

No branches or pull requests

3 participants