Comments (5)
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.
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.
Besides everyone loves Python 😄
from fmt.
👍 seems that Python becomes more popular lately. Thanks.
from fmt.
Implemented in version https://github.com/cppformat/cppformat/releases/tag/v0.11.0.
from fmt.
Related Issues (20)
- Does not compile with the FMT_PEDANTIC=ON and FMT_WERROR=ON options HOT 3
- Add support for alternative month format HOT 2
- P3142R0: Printing Blank Lines with println HOT 1
- MSVC errors when importing both fmt and std modules HOT 19
- Cannot use ostream support on fmt 9.x and 10.x HOT 1
- fmt::format_to + FMT_STRING with wide characters fails to compile HOT 1
- Invalid PDB file generated due to MSVC 2017 compatibility code HOT 6
- std::chrono::current_zone() is not meant to return the local time zone HOT 4
- It would be good to have a customizable separator in fmt::group_digits(...) HOT 1
- fmt::styled and fmt::formatter<std::string> parse deactivate colors/termaps HOT 1
- formatting of variant types HOT 3
- FMT_USE_NONTYPE_TEMPLATE_ARGS detection is wrong on trunk HOT 2
- Support for a single `char` separator in `fmt::join()` HOT 1
- Formatting for strings with custom allocators fails to compile HOT 2
- Advice for extending libfmt for GPU support? HOT 2
- xchar.h extra dependencies HOT 1
- cannot use in CUDA (+MSVC) for newest branch master HOT 1
- Question: what's the difference between string-like formatters and where are they defined? HOT 2
- fmt won't let me specialize a formatter to format mixed character types. HOT 2
- `fmt::isnan` triggers floating-point exception for NaN values HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fmt.