It can be worth considering why a language is designed or altered in certain ways to see if there was a tradeoff that made it seem worthwhile or easier than some other choice.
Python grew and there was regular pressure to add keywords which might break existing programs. So, yes, sometimes, a keyword was re-used in a different context. And, yes, it was not originally conceived in a purely object oriented context. If you wanted to start over and built a new language very similar to python, you might indeed make other choices now that seem more seamlessly to fit together. You could set aside and reserve hundreds of keywords or some way to extend keywords by insisting anything staring with "key_" cannot be used in a variable name. You might design all the main objects supported to all support a function that provides a length as well as every other method needed so it looks purely object oriented. But perhaps that would make it a tad harder to program it using other ways. As an example, I can ask some sort program to order the results by the length of items by passing it the function that does lengths as an argument. If instead all we had was a method, that might be a bit different and perhaps someone would simply make a tiny function that when called, invoked the method. So, we have a hybrid of sorts and have to live with it, warts and all, and some of the warts may be seen by some as beauty marks. -----Original Message----- From: Python-list <python-list-bounces+avi.e.gross=gmail....@python.org> On Behalf Of Chris Angelico via Python-list Sent: Sunday, January 14, 2024 7:32 AM To: python-list@python.org Subject: Re: Extract lines from file, add to new files On Sun, 14 Jan 2024 at 23:28, Left Right <olegsivo...@gmail.com> wrote: > Having worked with a bunch of different grammar languages, the one > used for Python isn't a recognizable BNF derivative. That might possibly be because it isn't? It's not BNF. It's PEG. Or are you a long way behind the times? > For example, you may say "functions in Python are > objects", but you cannot put a function definition in the head of the > for loop clause. What do you mean? for x in lambda: ...: ... Perfectly grammatical. ChrisA -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list