String joining design - Page 3 - Python Discussions
Jan 2, 2023 ... You're joining strings with strings, using a string separator. Why are you surprised its a string method? It certainly shouldn't be just a list ...
Jan 2, 2023 ... You're joining strings with strings, using a string separator. Why are you surprised its a string method? It certainly shouldn't be just a list ...
Dec 31, 2021 ... operators for performing arithmetic computations and string concatenation ... first Python command (or function, operator, statement ...
I’ll concede that ", ".join(str(i) for i in value) isn’t an obvious idiom, but once you’ve learned the components (string methods, the idiomatic way join works, generator expressions) it’s far more explicit and flexible than a dedicated function would be.
OT: Irrespective of f-strings, I really dislike the style of calling .join() on a string literal. I remember ages ago when we were debating how to add a string join function, there were arguments to making it either a …
Discussions on Python.org. TypeError: 'str' object is not callable.note the similarity on the code here – maybe you can remove some duplication? hint – the string .join() method could be helpful here.
Both of your methods take essentially the same time, since the nested loop doesn’t come into effect, while the simpler method above is nearly three times faster. On a very long string with many repeating segments, on the other hand