Skip to content
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

Implement string format method #116

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

Implement string format method #116

DoDaek opened this issue Oct 7, 2019 · 3 comments
Labels

Comments

@DoDaek
Copy link
Contributor

@DoDaek 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 label Oct 8, 2019
@ncw
Copy link
Collaborator

@ncw 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 DoDaek commented Oct 11, 2019

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

@tim-st
Copy link
Contributor

@tim-st tim-st commented Oct 11, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.