A mutable data type is a type of data can by changed. Lists for example. Data within a list can be changed, rearranged, removed, etc. Strings are one example of an immutable data type.
New strings can be built with slicing and dicing (then putting the pieces back together) but your building a new string and the original string stays the same.
Resources # https://nginx-playground.wizardzines.com/
None is the only value of the NoneType data type. Similar to null, nil or undefined from other programming languages.
Just like True and False boolean values None must be capitalized.
>>> spam = print('Hello!') Hello! >>> None == spam True >>> All functions in Python need to evaluate to a return value. Functions that don’t define a return value return None by default. If you use a return statement without a value None is returned.
...
Open files with the open() function. Pass it a string path for file you want to open. Returns a File object.
i>>> from pathlib import Path i>>> helloFile = open(Path.home() / 'hello.txt') i>>> helloFile <_io.TextIOWrapper name='/home/akraker/hello.txt' mode='r' encoding='UTF-8'> i>>> helloFile = open('/home/akraker/hello.txt') i>>> helloFile <_io.TextIOWrapper name='/home/akraker/hello.txt' mode='r' encoding='UTF-8'> Note, that you can only pass a Path object to the open() function as of Python 3.6+.
The open() function opens files in read-only mode by default.
...
Parameters are variables that contain arguments .
The partition() method splits the string using a separator string. Returns a tuple with string splits and separator.
>>> 'Hello, world!'.partition('o') ('Hell', 'o', ', world!') If the separator string can’t be found it will return the entire string with the second two strings as empty strings.
Arguments get passed to functions as references. When the function is called the values of the arguments are copied to the parameter variables. For lists and dictionaries a copy of the reference is used for the parameter.
def eggs(someParameter): someParameter.append('Hello') spam = [1, 2, 3] eggs(spam) print(spam) i[akraker@localhost python]$ python passingReference.py [1, 2, 3, 'Hello'] Because someParameter and spam both use a copy of the reference, the list is modified.
...
You can use the pathlib module to interact with file-paths on Windows or *nix-based systems.
i>>> from pathlib import Path i>>> Path('spam', 'bacon', 'eggs') PosixPath('spam/bacon/eggs') i>>> str(Path('spam', 'bacon', 'eggs')) 'spam/bacon/eggs' Note, for Windows systems this will return a WindowsPath object and corresponding path using back-slashes.
Concatenate paths # You can use the / operator to concatenate Path objects and strings.
i>>> Path('spam') / 'bacon' / 'eggs' PosixPath('spam/bacon/eggs') Note this is safer than using string concatenation or the join() method when dealing with file-paths, especially if cross-platform compatibility is important.
...
Source # PEP 8 – Style Guide for Python Code A Foolish Consistency is the Hobgoblin of Little Minds
How-to’s # Admin # MH Time Tracking Clarity Setups MH WTRs Installations # Install WordPress Install PrestaShop Install Joomla Install Magento Install Node.js Migrate Drupal Install R Install PHP-FFMpeg Install Apache SVN Webmin Installation ProFTPD Installation Install GCC for gRPC dependency Install Python 2.
...