[Baypiggies] Custom format a la datetime
Aahz
aahz at pythoncraft.com
Sat Apr 18 23:01:07 CEST 2015
On Sat, Apr 18, 2015, Santiago Basulto wrote:
>
> Hello everybody. I'm writing a CLI program to do some search. It's an
> internal tool. I'd like to provide the option to my user to format the
> results as he/she'd like. Something similar to strftime on the datetime
> module.
Which version of Python? You can use either regular string % formatting
with all versions of Python or the newer string formatting method in 2.6
and newer:
https://docs.python.org/2.7/library/stdtypes.html#string-formatting
https://docs.python.org/2.7/library/string.html#string-formatting
You probably want a special dict class that handles missing keys.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Need a book? Use your library!
More information about the Baypiggies
mailing list