gpython
gpython copied to clipboard
Implement string format method
python
>>> a = 'alpha'
>>> b = 'bravo'
>>> d = 'delta'
>>> origin = '{} {} charlie {}'
>>> new = origin.format(a, b, d)
>>> print(new)
alpha bravo charlie delta
>>> print(origin)
{} {} charlie {}
>>>
gpython
>>> a = 'alpha'
>>> b = 'bravo'
>>> d = 'delta'
>>> origin = '{} {} charlie {}'
>>> new = origin.format(a, b, d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FIXME line of source goes here
AttributeError: "'str' has no attribute 'format'"
>>> print(new)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FIXME line of source goes here
NameError: "name 'new' is not defined"
>>> print(origin)
{} {} charlie {}
>>>
Attribute error occured using string.
Yes gpython needs this :-)
The specification of the format language is here so it is reasonably complicated to do completely.
It may take some time, but I'll work it out. Thanks for your information :+1:
@DoDaek
You can have a look (or use it?) here.
The function should be callable using "".format and str.format
Waiting on response from @slongfield
https://github.com/slongfield/pyfmt/issues/15