Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    Can you elaborate on that? It's not that I don't believe you, I just want to understand why. Commented Oct 22, 2015 at 15:16
  • 5
    Sure. The most pythonic way would be to use one of the builtin functions rather than using a homegrown solution as much as possible. Commented Oct 22, 2015 at 15:21
  • @MadPhysicist saying that slicing is less pythonic because you should use in built functions is like saying ''.join(reversed(str)) is more pythonic than str[::-1], and we all know that's not true. Commented Feb 15, 2017 at 15:02
  • @NickA. That is not a very good analogy. The case you are using as an example is quite valid. However, (x + " " * 10)[:10] is in my opinion much more convoluted than using x.ljust(10). Commented Feb 15, 2017 at 17:03
  • @MadPhysicist I more meant that your comment "The most pythonic way would be to use one of the builtin functions" is not always accurate and that they aren't words to live by. Although in this case it certainly is. Commented Feb 15, 2017 at 17:24

lang-py