Guido van Rossum wrote: > \>> I hate calling methods on string literals, I think it looks very odd >>> to have code like this: >>> >>> "Displaying {0} of {1} revisions".format(x, y) >> Ugh! Good point. > > This objection was made years ago when we introduced > "separator".join(list_of_things), and I don't think ignoring it has > caused any casualties. In fact, it serves as an early reminder to the > user that string literals are, in fact, objects like all others. The other string literal method I personally use reasonably often is to create lists of strings by using "a list of strings".split() instead of ['a', 'list', 'of', 'strings'] (while the character count isn't all that different, I find the former is easier to both write and read without all those quotes and commas). It's a trick I've seen plenty of other people use as well. So I would agree that method invocation on literals (particularly string literals) is an already established language idiom. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia ---------------------------------------------------------------
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4