[melbourne-pug] string formatting / Format SPecific Mini Language

Josh Bode joshbode at gmail.com
Tue May 13 08:55:33 CEST 2014


However, I’m not sure exactly what that emoticon is, though… er, man with halo and beard, perhaps?

On 2014-05-13, at 4:50 pm, Josh Bode <joshbode at gmail.com> wrote:

> How about "{0:<{1}}".format(something, 10)
> 
> Cheers,
> Josh
> 
> On 2014-05-13, at 4:23 pm, David Crisp <dcrisp at netspace.net.au> wrote:
> 
>> I need to create a string that has a variable length of padding and im not sure how to do it.
>> 
>> For instance
>> 
>> some_string = ("{something:<40}".format(something = somethingelse))
>> 
>> will give me a 40 space padded display of something
>> 
>> 
>> What if, after a little bit of string concatination (for want of a abetter word)  I want to do the following:
>> 
>> string_length = len(some_other_string)
>> 
>> some_string = ("{something:<string_length}".format(something = somethingelse))
>> 
>> When I do this I get a ValueError: Invalid format specifier.
>> 
>> IS there a clean and neat way of doing the above?
>> 
>> Regards,
>> David Crisp
>> 
>> 
>> 
>> 
>> _______________________________________________
>> melbourne-pug mailing list
>> melbourne-pug at python.org
>> https://mail.python.org/mailman/listinfo/melbourne-pug
> 



More information about the melbourne-pug mailing list