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

Support basic type conversion builtin functions #228

Open
wixette opened this issue Jul 28, 2022 · 1 comment
Open

Support basic type conversion builtin functions #228

wixette opened this issue Jul 28, 2022 · 1 comment
Assignees
Labels
feature New feature or request

Comments

@wixette
Copy link
Contributor

wixette commented Jul 28, 2022

Without the following basic type conversion functions

bool()
str()
int()

It's hard to complete many simple tasks. For example, since SeedPython hasn't supported

f'Template string: {variable}'

yet, it's hard to mix strings and numbers in a single output line with the print() function like:

print(f'value = {value}')

Given there is no f'' template string, the following statement can be an alternative way for those cases:

print('value' + str(value))

Supporting basic type conversion functions will enable many possibilities.

BTW, repr() should be another story, which we can consider later, I think.

@wixette wixette added the feature New feature or request label Jul 28, 2022
@wixette
Copy link
Contributor Author

wixette commented Jul 28, 2022

And, given we have already provided the print() function, we need to consider Python template strings seriously sooner or later:

'Hello, %s' % name

'Hey %s, there is a 0x%x error!' % (name, errno)

'Hey %(name)s, there is a 0x%(errno)x error!' % { "name": name, "errno": errno }

'Hello, {}'.format(name)

'Hey {name}, there is a 0x{errno:x} error!'.format(name=name, errno=errno)

f'Hello, {name}!'

f"Hey {name}, there's a {errno:#x} error!"

This will be a big task. Above all these forms, maybe we can only support one or two of them.

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

No branches or pull requests

2 participants