Add ljust and rjust methods to str built-in type#3502
Merged
chrisnovakovic merged 1 commit intothought-machine:masterfrom Mar 23, 2026
Merged
Add ljust and rjust methods to str built-in type#3502chrisnovakovic merged 1 commit intothought-machine:masterfrom
ljust and rjust methods to str built-in type#3502chrisnovakovic merged 1 commit intothought-machine:masterfrom
Conversation
``` str.ljust(width[, fillchar]) str.rjust(width[, fillchar]) ``` These methods are equivalent to their Python namesakes: they return a copy of the string left-padded or right-padded with the character given by `fillchar` until it is `width` characters long. `fillchar` defaults to `' '` (i.e. a space).
toastwaffle
approved these changes
Mar 23, 2026
| - returns a copy of this string left-padded with the character given | ||
| in <code class="code">fillchar</code> (or the default <code class="code" | ||
| >' '</code> if no value is given) until it is <code class="code" | ||
| >width</code> characters long. |
Contributor
There was a problem hiding this comment.
Is it worth declaring here that this is done based on how Go counts characters(/runes)? Or are we happy to leave the "how long is a (piece of) string" nonsense unsaid?
Contributor
Author
There was a problem hiding this comment.
IMO it's best left unsaid for now, because I'm pretty sure string length operations are inconsistent in ASP and I'd rather people not draw inferences based on statements made in one part of the documentation that are omitted in others. I don't think it's the highest-priority task, but we should probably go through the language and make sure length operations on strings are all character-wise, not byte-wise, as they are in Python.
DuBento
pushed a commit
to DuBento/please
that referenced
this pull request
Mar 27, 2026
…ne#3502) ``` str.ljust(width[, fillchar]) str.rjust(width[, fillchar]) ``` These methods are equivalent to their Python namesakes: they return a copy of the string left-padded or right-padded with the character given by `fillchar` until it is `width` characters long. `fillchar` defaults to `' '` (i.e. a space).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
These methods are equivalent to their Python namesakes: they return a copy of the string left-padded or right-padded with the character given by
fillcharuntil it iswidthcharacters long.fillchardefaults to' '(i.e. a space).