Avatar ·

Why are Lambda functions needed?

📁 lambda, Advanced Python Topics, example, AI

While studying Python, I came across lambda functions. But I haven't yet found an example where they are really needed - only basic examples like print(lambda x, y: x**2 + y**2), where you could easily remove the functional wrapper. What are they really needed and useful for?

Avatar ·

Any clever student like me will quickly crack the Caesar cipher.

Separate the wheat from the chaff: just don't write the password inside the code, and the problem will solve itself. Additionally, you won't need to edit the code to connect to some other database, which improves convenience. As for where to write the password then — there are many options.

Environment variable

Any "adult" OS has certain global variables called environment variables. You can put the password there, and in Python read these variables. How to change environment variables depends on the specific OS (details can be found ), and in Python code, reading them might look something like this:


                            
                                Log in                            
                             to leave an answer                        

Blogs