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

Python string.strip() optional arguments not implemented #41

Closed
shaolo1 opened this issue Apr 19, 2016 · 7 comments
Closed

Python string.strip() optional arguments not implemented #41

shaolo1 opened this issue Apr 19, 2016 · 7 comments

Comments

@shaolo1
Copy link

shaolo1 commented Apr 19, 2016

Python

foo = 'foocba'
print(foo.strip('abc'))

foo
Generated javascript prints
foocba

@JdeH
Copy link
Collaborator

JdeH commented Apr 19, 2016

Indeed this was not yet done to keep the libraries as small as possible. Tried to cover the most common usage first. Probably will supply a more extensive lib in a later version.

@Michael-F-Ellis
Copy link

Can we reopen this one? I very much need a strip() that does more than trim whitespace. If not, can you suggest a workaround that will do the right thing in both Cpython and Transcrypt?
Thanks!

@mmjee
Copy link

mmjee commented Jun 23, 2017

Implementing this should be very easy, it's worth implementing.

@mmjee
Copy link

mmjee commented Jun 23, 2017

I suggest we reopen this, too.

@Michael-F-Ellis
Copy link

The following works for my immediate problem but it makes my skin crawl a little.

                while a.startswith('-'):
                    a = a[1:]
                while a.endswith('-'):
                    a = a[:-1]

@fzzylogic
Copy link

fzzylogic commented Jun 24, 2017

Don't think Javascript has anything that does that natively, so if Transcrypt did do so, it would probably compile to something like what you suggested, despite the discomfort that would induce :-). For example. The regex based suggested polyfill for native trim() at MDN is also interesting. Please mention what you settle on, could be useful. Perhaps one day one could have ones cake and eat it by having modules that provide closer cpython support at the cost of size / speed, thereby saving the core from bloat but providing the option to those that can live with that.

@Michael-F-Ellis
Copy link

@fzzylogic Good point! I think there are a couple of meta-issues here so I'm going to submit those separately to promote wider discussion.

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

No branches or pull requests

5 participants