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

Explanations for "Strings can be tricky sometimes!" are incomplete #67

Closed
jseakle opened this issue Jan 30, 2018 · 10 comments
Closed

Explanations for "Strings can be tricky sometimes!" are incomplete #67

jseakle opened this issue Jan 30, 2018 · 10 comments

Comments

@jseakle
Copy link

jseakle commented Jan 30, 2018

The main issue is that they do not address the third snippet at all, "a" * 20 vs "a" * 21.

I'm also very curious to know /why/ it's the case that

Strings that are not composed of ASCII letters, digits or underscores, are not interned. This explains why 'wtf!' was not interned due to !.

If it were just non-ASCII, that would make some sense, but what problems could interning a string with an exclamation point cause?

@sohaibfarooqi
Copy link
Contributor

You can read This SO post for details. It covers everything you need to know.

@jseakle
Copy link
Author

jseakle commented Feb 13, 2018

The existence of an SO post doesn't mean the explanation section isn't incomplete. The main issue is that it does not address the third snippet at all, "a" * 20 vs "a" * 21.

@sohaibfarooqi
Copy link
Contributor

@jseakle I completely agree with you. Even I noticed this too when I was reading the explanation portion. Then I searched on SO and found the post that I posted in my earlier comment.

Someone really have to improve the explanation for this portion.

@sheljohn
Copy link

+1, I was looking for the same explanation :) Would @satwikkansal be able to add a few words about this? Would a PR make it easier?

sheljohn pushed a commit to sheljohn/wtfpython that referenced this issue Feb 25, 2018
satwikkansal added a commit that referenced this issue Feb 25, 2018
@satwikkansal
Copy link
Owner

Alright guys, really sorry for the ignorance. I've fixed this up in a0100a8 Let me know if things are still unclear.

@sheljohn
Copy link

@satwikkansal Just submitted a PR about this :) Should I delete it? I think it would be good to mention that is should not be used for value comparison.

@satwikkansal
Copy link
Owner

If it were just non-ASCII, that would make some sense, but what problems could interning a string with an exclamation point cause?

A look at the source code shows that this is defined here used here to decide if a string should be interned or not.

@satwikkansal
Copy link
Owner

@sheljohn oops, I didn't knew that, I'm having a look at your PR (y)

@satwikkansal
Copy link
Owner

Should I delete it? I think it would be good to mention that is should not be used for value comparison.

@sheljohn left a few comments at the PR. I guess maybe we should only go with the typo (fullstop) change for the time being.

@satwikkansal
Copy link
Owner

Alright everyone, closing this now. Feel free to reopen the issue if explanation is still confusing/incorrect/insufficient.

muscliary pushed a commit to muscliary/wtfpython that referenced this issue Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants