filbert icon indicating copy to clipboard operation
filbert copied to clipboard

String formatting

Open nwinter opened this issue 11 years ago • 7 comments

How hard will it be to get Python string formatting / interpolation, where we can do things like:

print("My name is %s." % name)

nwinter avatar Jul 14 '14 21:07 nwinter

I'll work on this @nwinter with the vocal support of @differentmatt. Will keep you up to date how it goes.

GlenDC avatar Jul 14 '14 22:07 GlenDC

I was looking at this, looks like in python 3, the newer format method might be a better way to go?

'My name is {0}'.format(name)

I have no idea which would be easier to implement and I'd be happy with either version.

http://stackoverflow.com/questions/5082452/python-string-formatting-vs-format

nemoyatpeace avatar Jul 16 '14 00:07 nemoyatpeace

@nemoyatpeace thank you for the input. The .format method is a way better approach as it seems. It can do more, it is easier to use and it will also be easier to implement as far as I can see. So I'll go with this one first.

@nwinter @differentmatt if you guys want, I can also try to implement the % modula format version, although python users are actually saying that you should only use it when you don't know about the .format version or when you want to support backwards compatibility to old python versions (such as 2.5). Let me know what you guys think about this!

GlenDC avatar Jul 16 '14 07:07 GlenDC

I'll defer to @nwinter, since he opened this issue.

differentmatt avatar Jul 16 '14 16:07 differentmatt

Was going to start on it yesterday. But my hdd died. Going to try to find a new one. Will keep you posted.

GlenDC avatar Jul 21 '14 05:07 GlenDC

Ok my laptop is working again with an ssd and i'm installed in the UK. Will start digging into the code while I start solving this solution, so that I can move on to new issues soon. Will keep you posted.

GlenDC avatar Jul 26 '14 19:07 GlenDC

Great, keep us posted!

differentmatt avatar Jul 26 '14 21:07 differentmatt