This article is an example of map, any, all function usage in python. Shared for your reference. Specific analysis is as follows:
Recently, I want to learn python, has been more concerned about python, yesterday in python bar to see a post asking how to ask how to determine the password in python whether it meets the specifications, back to the post there are a lot of loops, in addition to this there is one without a loop, the code is very concise, the following is the code:
def volid(pwd): a = any(map(,pwd)) b = any(map(,pwd)) c = any(map(,pwd)) d = not all(map(,pwd)) return all([a,b,c,d])
here isupper islower isdigit isalnum function are very good to understand, is to determine is not uppercase, is not lowercase, is not a number, is not all numbers and letters (in turn is to determine whether there is no other symbols), and here the map function is the back of the set of each element with the first parameter function to perform a return of a bool type of collection, the outermost any and all function is easier to understand, you can use "or" and "with" to understand, if the parameter set has a true, any function returns true, equivalent to all elements of the "or" a bit, only when the parameter set all true, all function returns true, other cases are returned false, so if the solid function passes a string containing uppercase and lowercase alphanumeric and special symbols, abcd is assigned to true, and finally return true, so this function can determine the password is complex enough.
Leave yourself the question of how to write a function that is more concise if it requires only two of the four terms to be satisfied. If you are interested, you can do some hands-on practice.
I hope that what I have described in this article will help you in your Python programming.