Git Product home page Git Product logo

Comments (5)

patlecat avatar patlecat commented on May 18, 2024

What is your argument for going for Python's str.format instead of printf in the first place? I'm not familiar with it.

from fmt.

vitaut avatar vitaut commented on May 18, 2024

The problem with printf syntax is when you have type information, much of specification becomes redundant, for example, length specifiers and u. That's because it serves two functions in the original printf - specify output format and specify the type of the argument. But more importantly, the str.format syntax is extensible:

The syntax for format specifiers is open-ended, since a class can override the standard format specifiers. In such cases, the str.format() method merely passes all of the characters between the first colon and the matching brace to the relevant underlying formatting method.

I plan to add a mechanism to create format specifiers for user-defined types. This will be extremely useful for things like dates, complex numbers, etc:

Print("{:%B %d, %Y}", date);

Doing the same with printf would be rather awkward as Boost Format demonstrates.

from fmt.

vitaut avatar vitaut commented on May 18, 2024

Besides everyone loves Python 😄

from fmt.

patlecat avatar patlecat commented on May 18, 2024

👍 seems that Python becomes more popular lately. Thanks.

from fmt.

vitaut avatar vitaut commented on May 18, 2024

Implemented in version https://github.com/cppformat/cppformat/releases/tag/v0.11.0.

from fmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.