Bring Your Logic using Python
341 subscribers
109 photos
1 video
4 files
544 links
Logic building using Python : Materials, links, e-books and Code snippets
Download Telegram
In #Python you can chain comparison operators ...

Instead of writing "1 < a and a < 10" you can write "1 < a < 10", a bit more concise.
πŸ”΄πŸŸ‘πŸŸ’ Here is a three-way comparison of the three built-in string formatting methods in Python 🐍

If you want to include the same variable(s) twice or more, then I think that the `.format` method is the most convenient method.

Take a look for yourself
did you know that you can use functions as values in a Python dictionary? 🐍

You can define the lambda function as a reference to the keys of the dictionary, and then you can pass arguments to it and evaluate it.

😘 Unsolicited {dict} pic:
This can be reduced further.

Party trick to avoid the lambdas.
The funny thing is the space is the only magic here; Python is a truly object-oriented programming language, so integers have methods too. Add that * is just calling __mul__() means you can do that to any object.

Now knowing you need that space to make the parser happy?!!πŸ‘΄
πŸ‘΄ #Python wisdom for the day: you can directly call methods on integers (remember, Python is fully object-oriented; no automatic boxing needed here πŸ˜‰)
Python makes it easy to create an uncompressed tar file. All you need is the `tarfile` library, which comes with Python!
🐍Python Tip: To convert your strings to be URL friendly. For example, when constructing an API request/query strings, you can use urllib's quote method like so πŸ‘†πŸ»
#networkautomation #python #python3