Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider also something like
print(f'Unknown color specified: {bytes(input, "utf-8")}')
to catch any unprintable characters. Edit: (or white-space characters that need quotes to be seen)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that, but I'm not sure if I like the byte indicator around the color string.
Unknown color specified: b'OGYW'
But I will include it if you want 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str(bytes(input, "utf-8"))[1:]
instead if that is the only thing you don't like.if-else
, it is also possible (if you want, but not required IMHO - a matter of taste, I guess) to avoid the quotes when they are not strictly needed:However, I don't insist. It's just a suggestion in case someone find it useful. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm out of the loop, but why don't we stick to the suggested
?
Are we really worried people will try to use emojis and non-printable characters as colors? 😛
For stray whitespace characters,
should be enough to catch them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any of them are OK with me. I just wanted to menton ideas that have been useful in other projects, but you decide what is needed in this project. My reply was not intended as a fight for my suggestion, but simply a correction of the draw-back that was commented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, just trying to understand the motivation for the idea. I think for now it's safe to keep it as-is :)