very-cool-group

microsoft-build-tools

When you install a library through pip on Windows, sometimes you may encounter this error:

error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

This means the library you're installing has code written in other languages and needs additional tools to install. To install these tools, follow the following steps: (Requires 6GB+ disk space)

1. Open https://visualstudio.microsoft.com/visual-cpp-build-tools/. 2. Click Download Build Tools >. A file named vs_BuildTools or vs_BuildTools.exe should start downloading. If no downloads start after a few seconds, click click here to retry. 3. Run the downloaded file. Click Continue to proceed. 4. Choose C++ build tools and press Install. You may need a reboot after the installation. 5. Try installing the library via pip again.

return

A value created inside a function can't be used outside of it unless you return it.

Consider the following function:

def square(n):
    return n * n
If we wanted to store 5 squared in a variable called x, we would do: x = square(5). x would now equal 25.

Common Mistakes

>>> def square(n):
...     n * n  # calculates then throws away, returns None
...
>>> x = square(5)
>>> print(x)
None
>>> def square(n):
...     print(n * n)  # calculates and prints, then throws away and returns None
...
>>> x = square(5)
25
>>> print(x)
None
Things to note
- print() and return do not accomplish the same thing. print() will show the value, and then it will be gone.
- A function will return None if it ends without a return statement.
- When you want to print a value from a function, it's best to return the value and print the function call instead, like print(square(5)).