On 07/11/2019 13:36, Stephen Waldron wrote:
This is how it is at the moment, however it may be more agreeable, especially 
if that is the only purpose of the function, for python users to be able to 
define new functions inside of function calls.

No, not seeing it. Sorry, I don't think "I don't want to use up a precious, precious name in this namespace" is a good enough reason to do anything, never mind something with a lot of implicit naming going on. Suppose you had been good and made a module of your Book example. What is someone reading your code supposed to make of this?

    import books

    my_books = [
        books.Book("Triplanetary", 'E.E. "Doc" Smith'),
        books.Book("Foundation", "Isaac Asimov")
    ]

    books.doToBooks(my_books):
        print(book.name, ":", book.author)
    then:
        if book.name == "Foundation":
            print("READ THIS FIRST!")

The name "book" has just appeared out of thin air, and without stopping and reading the code of your module they will have to guess at what it is. Now in this case their first guess is probably right, but this is a toy example and just as easily written with lambdas if you're that worried about using up names.

-10 from me.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to