Skip to content

Implement string format method #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
DoDaek opened this issue Oct 7, 2019 · 4 comments
Open

Implement string format method #116

DoDaek opened this issue Oct 7, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@DoDaek
Copy link
Contributor

DoDaek commented Oct 7, 2019

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.

@ncw ncw added the enhancement New feature or request label Oct 8, 2019
@ncw
Copy link
Collaborator

ncw commented Oct 8, 2019

Yes gpython needs this :-)

The specification of the format language is here so it is reasonably complicated to do completely.

@DoDaek
Copy link
Contributor Author

DoDaek commented Oct 11, 2019

It may take some time, but I'll work it out.
Thanks for your information 👍

@ghost
Copy link

ghost commented Oct 11, 2019

@DoDaek
You can have a look (or use it?) here.
The function should be callable using "".format and str.format

@drew-512
Copy link
Contributor

Waiting on response from @slongfield

slongfield/pyfmt#15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants