[Ansible Galaxy] Use Ansible bjoernalbers.macos_pf to install Packet Filter (PF) Firewall
Ansible Role: macos_pf
An Ansible Role to manage the Packet Filter (pf) Firewall of macOS.
An Ansible Role to manage the Packet Filter (pf) Firewall of macOS.
Paramiko is a pure-Python (2.7, 3.4+) implementation of the SSHv2 protocol, providing both client and server functionality. It provides the foundation for the high-level SSH library Fabric, which is what we recommend you use for common client use-cases such as running remote shell commands or transferring files.
Direct use of Paramiko itself is only intended for users who need advanced/low-level primitives or want to run an in-Python sshd.
Ansible works against multiple managed nodes or “hosts” in your infrastructure at the same time, using a list or group of lists known as inventory. Once your inventory is defined, you use patterns to select the hosts or groups you want Ansible to run against.
chinese_pinyin is a gem to initialize Chinese holidays, or add and remove your holidays.
A role that installs Anaconda | The World’s Most Popular Data Science Platform - https://www.anaconda.com/. Please consider andrewrothstein.conda-env
for managing your Conda environments declaratively with Ansible too!
Anaconda is the birthplace of Python data science. We are a movement of data scientists, data-driven enterprises, and open source communities
Installs Vagrant by HashiCorp - https://www.vagrantup.com/.
Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the “works on my machine” excuse a relic of the past.
Installs Oracle Virtualbox.
VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL) version 2. See “About VirtualBox” for an introduction.
Sometimes, you will need to implement __str__
or __repr__
methods for your class. Do you know what they do? Is there any difference between them? The answer to this question can be found by searching. If it happens to be the first time you have seen this question, you might as well take a look.
The print statement and str()
built-in function uses __str__
to display the string representation of the object while the repr()
built-in function uses __repr__
to display the object.
Following are differences:
__repr__
is used to generate a formal representation. It may be considered as a method of serializing an object, and in principle, it may be able to deserialize back to an object. It is mainly used for debugging and development. It’s goal is to be unambiguous and str’s is to be readable.__str__
is used to generate informal representations. Format or print will call it to generate a “friendly” display for the user. It is used for creating output for end user.
If you need to implement it yourself, generally implement __str__
.
Executing repr(obj)
in Python can get the string representation of obj, and this operation is equivalent to calling obj.__repr__()
. And this string means that may be able to deserialize back to obj itself. Look at the following code:
1 | x = [1,2,3] |
We see that’[1, 2, 3]’ (note that there is a space after the comma) is the string representation of the data [1,2,3]
, the original data can be obtained by deserializing with eval. So what if the variable is a custom class?
1 | class MyClass: |
As you can see, repr(x)
gives the type of object and the ID (memory address) of the object. But if we try to deserialize with eval(repr(x))
, it will fail. So being able to deserialize is actually a convention, not a compulsion. We try to override the default implementation:
1 | class MyClass: |
You can see that the coverage of __repr__
has an effect, and it can be deserialized normally.
The above few examples are all to illustrate what is the use of the string generated by repr.
repr does not force the generated string to be deserialized
The string generated by repr is generally used for debugging, so the generally generated string should contain as much information as possible, and the information should be as clear as possible (for example, the ID is used to distinguish two different objects in the default implementation).
Don’t use repr and eval for serialization/deserialization, use pickle or json.
str is used to display
The obj.__str__()
method will be called during print(obj)
or '{}'.format(obj)
, generally to provide users with a “friendly” display, so __str__
does not return in principle like __repr__
Values are agreed, and you can do whatever you want.
1 | >>> from datetime import datetime |
In addition, the default implementation of __str__
calls the __repr__
method directly. Therefore, if the __repr__
method is overridden, the result of __str__
will also change.
[1] str() vs repr() in Python - GeeksforGeeks - https://www.geeksforgeeks.org/str-vs-repr-in-python/
[2] str() vs repr() in Python? - https://www.tutorialspoint.com/str-vs-repr-in-python
Installs Homebrew on MacOS, and configures packages, taps, and cask apps according to supplied variables.
Go’s slice type provides a convenient and efficient means of working with sequences of typed data. Slices are analogous to arrays in other languages, but have some unusual properties. This article will look at what slices are and how they are used.