Visit your to-do list to manage your tasks.
- ``` - -1. Create a new directory of `src/routes/todo`. This creates a new `/todo` route for your application. - -1. Add a `+page.js` file within the `src/routes/todo` directory, and give the file the contents shown here. The `load` function runs before the page renders, usually to load data. The example here simply uses some static data, but the function is capable of fetching data from other files or services: - - ```file {title="src/routes/todo/+page.js"} - /** @type {import('./$types').PageLoad} */ - export function load({ params }) { - return { - todoList: ['Test 1', 'Test 2', 'Test 3'], - } - } - ``` - -1. Add a `+page.svelte` file within the `src/routes/todo` directory, and give the file the contents shown here. Annotations are provided throughout the code here to help break down what each part does. Overall, this file defines the structure of the to-do list and the functions for handling actions on the list: - - ```file {title="src/routes/todo/+page.svelte"} - - -Add a to-do item
-{todoItem}
- {:else} -Nothing to do!
- {/each} -{{getVersion()}}
-foo
-foo
-Problem accessing '/1.1/statuses/filter.json'. Reason:\n" + - '
Unauthorized\n' + - '\n' + - '\n', - statusCode: 401 -} -{{< /output >}} - -This error indicates that incorrect keys were copied into your `.env` file. You may have also associated the `.env` key names with the wrong credential from the Twitter developer portal. Review the table below for the correct associations between the `.env` file and the Twitter developer portal credentials. - -| .env Key Name | Twitter Developer Portal Credential Name | -|---------------|------------------------------------------| -| `consumer_key` | API Key | -| `consumer_secret` | API Secret Key | -| `access_token` | Access Token | -| `access_token_secret` | Access Token Secret | - -If you're not sure whether your keys are correct, you can regenerate them inside the Twitter developer portal. See the [Regenerate API Keys and Tokens](https://developer.twitter.com/en/docs/authentication/guides/authentication-best-practices) section of Twitter's documentation for instructions. - -### Troubleshooting Twitter Read Only Application Cannot POST Error - -When your bot attempts to tweet, you may see an error like this in its logs: - -{{< output >}} -Read-only application cannot POST. -{{< /output >}} - -This error indicates that your app's permissions are set to Read Only in the Twitter developer portal. Follow the instructions in the [Give your Twitter App Read and Write Permissions](#give-your-twitter-app-read-and-write-permissions). This section shows how to switch to Read and Write permissions and how to regenerate your Access Token and Access Token Secret. \ No newline at end of file diff --git a/docs/guides/development/nodejs/use-nightmarejs-to-automate-headless-browsing/index.md b/docs/guides/development/nodejs/use-nightmarejs-to-automate-headless-browsing/index.md deleted file mode 100644 index d629b29db01..00000000000 --- a/docs/guides/development/nodejs/use-nightmarejs-to-automate-headless-browsing/index.md +++ /dev/null @@ -1,158 +0,0 @@ ---- -slug: use-nightmarejs-to-automate-headless-browsing -title: 'Use Nightmare.js to Automate Headless Browsing' -description: 'Automate browsing tasks with Nightmare.js, a high-level browser automation library.' -og_description: 'Nightmare.js is an automated, headless browsing tool that can be configured to self-navigate websites, automate data scraping, and quicken QA.' -authors: ["Nashruddin Amin"] -contributors: ["Nashruddin Amin"] -published: 2017-10-09 -keywords: ["nightmare.js", " node.js", " headless browser", " automation"] -tags: ["automation", "ubuntu"] -license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)' -external_resources: - - '[Nightmare.js Homepage](http://www.nightmarejs.org/)' - - '[Nightmare.js Github Repository](https://github.com/segmentio/nightmare)' -audiences: ["intermediate"] -concentrations: ["Scripting, Automation, and Build Tools"] -languages: ["javascript"] -aliases: [] ---- - - - -**Nightmare.js** is a high-level browser automation library, designed to automate browsing tasks for sites that don't have APIs. The library itself is a wrapper around [Electron](https://electron.atom.io/), which Nightmare.js uses as a browser to interact with web sites. This guide helps you install Nightmare.js on Ubuntu 16.04 and run automation scripts without the need for a graphical user interface. - -## Before You Begin - -1. Familiarize yourself with our [Getting Started](https://techdocs.akamai.com/cloud-computing/docs/getting-started) guide and complete the steps for setting your Linode's hostname and timezone. - -2. This guide will use `sudo` wherever possible. Complete the sections of our [Securing Your Server](https://techdocs.akamai.com/cloud-computing/docs/set-up-and-secure-a-compute-instance) to create a standard user account, harden SSH access and remove unnecessary network services. - -3. Update your system: - - sudo apt-get update && sudo apt-get upgrade -{{< note >}} -This guide is written for a non-root user. Commands that require elevated privileges are prefixed with `sudo`. If you’re not familiar with the `sudo` command, see the [Users and Groups](/cloud/guides/linux-users-and-groups) guide. - -{{< /note >}} - -## Install Node.js - -The Ubuntu 16.04 repository is slower to release recent versions of Node.js. Install the most recent available version through the NodeSource PPA (formerly Chris Lea's Launchpad PPA). - -1. Install the NodeSource PPA: - - curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - - - {{< note respectIndent=false >}} -This command fetches the latest version of Node.js 6. To install a [specific version](https://nodejs.org/en/download/releases/), replace the `6.x` in this example. - -{{< /note >}} - -2. Install Node.js and NPM with the following command: - - sudo apt-get install -y nodejs - -3. Confirm that Node.js is successfully installed: - - node --version - -4. Check that the NPM command-line tool is successfully installed as well: - - npm --version - -## Install Nightmare.js - -To avoid installing the Node packages for the system globally, install Nightmare.js in a specific directory. This examples creates a `automation` directory within the current user's home directory as the base the project. - -1. Create and switch to the `automation` directory: - - mkdir ~/automation && cd ~/automation - -2. Initialize an NPM project. NPM prompts you to provide a name, repository, and other details for the project. Accept the default values or assign whatever names your want. To accept the defaults automatically, add the `-f` force flag to this example: - - npm init - -3. Install Nightmare.js: - - npm install --save nightmare - -## Create and Run the Automation Script - -Nightmare.js is an NPM module, so it can be imported from within a Node.js script. Use these examples to write a simple script that will search Linode's documentation for guides about Ubuntu. - -1. Nightmare.js uses the Electron browser and requires an X server. Install `xvfb` and its dependencies so that you can run graphical applications without display hardware: - - sudo apt-get install -y xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps clang libdbus-1-dev libgtk2.0-dev libnotify-dev libgnome-keyring-dev libgconf2-dev libasound2-dev libcap-dev libcups2-dev libxtst-dev libxss1 libnss3-dev gcc-multilib g++-multilib - -2. Create `linode.js` inside the automation directory and add the following: - - {{< file "~/automation/linode.js" javascript >}} -const Nightmare = require('nightmare'); -const nightmare = Nightmare({show: true}); - - -nightmare - .goto('https://www.linode.com/docs') - .insert('.ais-SearchBox-input', 'ubuntu') - .click('.ais-SearchBox-submit') - .wait('.ais-Hits-list') - .evaluate(function() { - let searchResults = []; - - const results = document.querySelectorAll('a.c-search__result__link'); - results.forEach(function(result) { - let row = { - 'title':result.innerText, - 'url':result.href - } - searchResults.push(row); - }); - return searchResults; - }) - .end() - .then(function(result) { - result.forEach(function(r) { - console.log('Title: ' + r.title); - console.log('URL: ' + r.url); - }) - }) - .catch(function(e) { - console.log(e); - }); - -{{< /file >}} - - -3. Run the script: - - xvfb-run node linode.js - - The script visits the [Linode docs](/cloud) page, enters 'Ubuntu' into the input box, and clicks the submit button. It then waits for the results to load and prints the url and title each entry on the first page of results. - - The output will resemble the following: - - Title: How to Install a LAMP Stack on Ubuntu 16.04 - URL: https://www.linode.com/docs/web-servers/lamp/install-lamp-stack-on-ubuntu-16-04 - Title: Install and Configure MySQL Workbench on Ubuntu 16.04 - URL: https://www.linode.com/docs/databases/mysql/install-and-configure-mysql-workbench-on-ubuntu - Title: Install MongoDB on Ubuntu 16.04 (Xenial) - URL: https://www.linode.com/docs/databases/mongodb/install-mongodb-on-ubuntu-16-04 - ... - -## Add a Cron Job to Run the Automation Script - -This example automates the script to run once every hour. It changes to the `~/automation/` directory, runs the scraping script, and saves the output to a file with a unique filename that includes the date and time it ran. - -For more information about using Cron, see our [Schedule Tasks with Cron](/cloud/guides/schedule-tasks-with-cron) guide. - -1. Open the crontab file: - - crontab -e - -2. Add the following line to the end of the file: - - {{< file "crontab" cron >}} -0 * * * * cd ~/automation && xvfb-run node linode.js >> data_$(date +\%Y_\%m_\%d_\%I_\%M_\%p).txt - -{{< /file >}} diff --git a/docs/guides/development/python/check-python-version/index.md b/docs/guides/development/python/check-python-version/index.md deleted file mode 100644 index 9c6b07f37db..00000000000 --- a/docs/guides/development/python/check-python-version/index.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -slug: check-python-version -title: "Check Your Python Version" -title_meta: "How to Check Which Python Version Is Installed" -description: "Knowing your Python version can make the difference between an application running or frustratingly failing. Thankfully, there is a quick command, and even some Python script, to check your currently installed Python version. Find out all you need to know about getting your Python version in this guide." -authors: ["Nathaniel Stickman"] -contributors: ["Nathaniel Stickman"] -published: 2022-08-15 -keywords: ['check python version','how to check python version','python version command'] -license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)' -external_resources: -- '[phoenixNAP: How to Check Python Version in Linux, Mac, & Windows](https://phoenixnap.com/kb/check-python-version)' -- '[LearnPython: How to Check Your Python Version](https://learnpython.com/blog/check-python-version/)' ---- - -Python reigns as one of the most popular programming languages, with a wide range of programs and developer tools relying on it. In fact, your system likely already has at least one version of Python installed. - -Many tools and Python development libraries require a particular version of Python. Thus, you may want to know where you can find information on your installed Python version. This can help you make decisions about compatibility, upgrades, and more. - -This tutorial shows you how to check your Python version, for both Python 2 and Python 3. Here, you can find the command line method as well as a Python script method for retrieving the current Python version. - -## How to Check the Python Version from the Command Line - -The Python command comes with a command line option of `--version` that allows you to see your installed version. - -It works just as straightforwardly as it sounds. Enter the following command from your command line, and you should get an output similar to the one shown below: - - python --version - -{{< output >}} -Python 3.8.10 -{{< /output >}} - -### Python 2 vs Python 3 - -Some systems distinguish between Python 2 and Python 3 installations. In these cases, to check your version of Python 3, you need to use the command `python3` instead of `python`. - -In fact, some systems use the `python3` command even when they do not have Python 2 installed alongside Python 3. In these cases, you only have the `python3` command. - -The command for checking the installed version of Python 3 remains otherwise the same - just use `python3` with the `--version` option: - - python3 --version - -## How to Check the Python Version from Python - -You can also check your installed Python version from within Python itself. Using either a script or the Python shell, you can use one of the code snippets below to print your Python version. - -Both options work equally well regardless of your system. The choice of which option to use really comes down to what format you want the output in. - -### Using sys - -The `sys` module has a variable you can reference to get the current Python version. Below you can see an example of how the `sys` module's `version` variable renders the current Python version. This code first imports the `sys` module then prints out the contents of the `version` variable: - -```python -import sys - -print(sys.version) -``` - -{{< output >}} -3.8.10 (default, Jun 22 2022, 20:18:18) -[GCC 9.4.0] -{{< /output >}} - -As you can see, the `sys.version` variable contains more information about your installed Python version than just the number. For that reason, `sys` is a good module to turn to when you want more verbose version information. - -### Using platform - -The `platform` module includes a function that fetches the current version of Python. The example code below uses this function to print the current Python version number. It first imports the `platform` module; then, the `python_version` function returns the version number to the `print` function: - -```python -import platform - -print(platform.python_version()) -``` - -{{< output >}} -3.8.10 -{{< /output >}} - -The output from the `platform.python_version` is more minimal compared to the `sys` module's `version` variable. This makes the `platform` module more useful for cases when you only need the version number. For example, this method helps when you want to design a program to parse the Python version and act accordingly. - -## Conclusion - -With that, you have everything you need for checking your current Python version. The steps above cover you whether you need to see the Python version from the command line or from within a Python script. - -You can continue learning about Python with our collection of [Python guides](/cloud/guides/development/python). We cover everything from fundamental Python concepts to building Python web applications. diff --git a/docs/guides/development/python/create-a-python-virtualenv-on-centos-8/index.md b/docs/guides/development/python/create-a-python-virtualenv-on-centos-8/index.md deleted file mode 100644 index 17bb5333bc5..00000000000 --- a/docs/guides/development/python/create-a-python-virtualenv-on-centos-8/index.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -slug: create-a-python-virtualenv-on-centos-8 -title: Creating a Python Virtual Environment on CentOS 8 -title_meta: How to Create a Python Virtual Environment on CentOS 8 -description: This guide provides a brief introduction to Python virtual environments using the virtualenv tool on CentOS 8. -authors: ["Linode"] -contributors: ["Linode"] -published: 2017-08-13 -modified: 2020-04-07 -keywords: ["python", "python virtual environment", "virtualenv", "centos 8"] -tags: ["python","centos"] -license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)' -external_resources: -- '[virtualenv Official Documentation](http://virtualenv.pypa.io/)' -audiences: ["beginner"] -languages: ["python"] -image: Python_virtualenv_CentOS8.png -relations: - platform: - key: python-virtual-env - keywords: - - distribution: CentOS 8 -aliases: [] ---- - -## What is a Python Virtual Environment? - -A Python virtual environment is an isolated project space on your system that contains its own Python executable, packages, and modules. Your Python applications and projects often have their own specific dependencies. With a virtual environment you can manage each of your project's distinct dependencies without having them interfere with each other. You can use the [*virtualenv*](https://pypi.org/project/virtualenv/) tool to create a virtual environment on your system. This guide will show you how to use virtualenv to create and run a Python virtual environment on a CentOS 8 Linode. - - -## Before You Begin - -1. Complete the [Getting Started](https://techdocs.akamai.com/cloud-computing/docs/getting-started) and [Securing Your Server](https://techdocs.akamai.com/cloud-computing/docs/set-up-and-secure-a-compute-instance) guides to prepare your system. - -1. Update your system: - - sudo yum update - - {{< note respectIndent=false >}} -This guide is written for a non-root user. Commands that require elevated privileges are prefixed with `sudo`. If you're not familiar with the `sudo` command, you can check our [Users and Groups](/cloud/guides/linux-users-and-groups) guide. - {{< /note >}} - -## Create a Python Virtual Environment -{{< note >}} -CentOS 8 does not include any version of Python by default. To install Python on CentOS 8, read our guide on [installing Python 3 on CentOS 8](/cloud/guides/how-to-install-python-on-centos-8) -{{< /note >}} - -1. To install Python's virtual environment: - - sudo yum install virtualenv - -1. Create a `python-environments` directory in your user's home directory and navigate to it: - - mkdir ~/python-environments && cd ~/python-environments - -1. Create a Python virtual environment. By default, virtualenv attempts to use your system's default Python interpreter to create a new environment. Replace `env` with the name you would like to assign to your virtual environment. - - virtualenv env - - {{< note respectIndent=false >}} -If your CentOS 8 system has another version of Python installed and you'd like to use it to create your virtual environment, use the e`--python` option to designate it. For example: - - virtualenv --python=python2.7 env - {{< /note >}} - -1. Validate that your environment is installed with the version of Python that you expect: - - ls env/lib - - You should see your `env` environments Python version: - - {{< output >}} -python3.6.8 - {{ output >}} - -## Activate Your Virtual Environment - -1. Activate the newly created virtual environment: - - source env/bin/activate - - The name of the working environment appears in parentheses after it's created. - - {{< output >}} -(env) example_user@hostname:~/python-environments$ - {{ output >}} - - You can now begin installing Python packages and libraries that will remain isolated to your virtual environment. - -## Deactivate a Virtual Environment - -1. To deactivate an active virtual environment, issue the following command: - - deactivate - - Your virtual environment is deactivated and you should no longer see its name listed next to your command line's prompt - - {{< output >}} -example_user@hostname:~/python-environments$ - {{ output >}} diff --git a/docs/guides/development/python/how-to-use-unicode-in-python3/index.md b/docs/guides/development/python/how-to-use-unicode-in-python3/index.md deleted file mode 100644 index 5890541893a..00000000000 --- a/docs/guides/development/python/how-to-use-unicode-in-python3/index.md +++ /dev/null @@ -1,399 +0,0 @@ ---- -slug: how-to-use-unicode-in-python3 -title: "How to Use Unicode in Python 3" -title_meta: "Using Unicode in Python 3" -description: 'This guide introduces the concept of Unicode to developers, explains how Python handles unicode, and demonstrates how to handle common errors' -authors: ["Jeff Novotny"] -contributors: ["Jeff Novotny"] -published: 2023-03-20 -keywords: ['Python unicode','Unicode python','Unicode error python','Python unicode to string'] -tags: ['python'] -license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)' -external_resources: -- '[Python Unicode Documentation](https://docs.python.org/3/howto/unicode.html)' -- '[Unicode site](https://home.unicode.org/)' -- '[Unicode 14.0 documentation](https://www.unicode.org/versions/Unicode14.0.0/)' -- '[Wikipedia ASCII page, including code points](https://en.wikipedia.org/wiki/ASCII)' -- '[Wikipedia UTF-8 page](https://en.wikipedia.org/wiki/UTF-8)' -- '[RFC 3629](https://datatracker.ietf.org/doc/html/rfc3629)' -- '[An explanation of the Unicode standard](https://jkorpela.fi/unicode/guide.html)' -- '[Python background on lexical analysis](https://docs.python.org/3/reference/lexical_analysis.html)' ---- - -Most of the time, using [*Unicode*](https://home.unicode.org/) characters in Python does not require extra effort. However, sometimes encoding and decoding do not work properly, which results in errors. To resolve these issues, this guide helps you understand how Python encodes and decodes Unicode. Fortunately, the Python library includes some powerful and useful utilities and built-in functions to manage these tasks. This guide introduces Unicode and the [*UTF-8*](https://en.wikipedia.org/wiki/UTF-8) character encoding and explains how Python handles Unicode. It also discusses some common Python Unicode errors and demonstrates how to resolve them. - -For an in-depth explanation of Unicode, read on, otherwise jump to [How Does Python Implement Unicode?](#how-does-python-implement-unicode) - -## An Introduction to Unicode on Python - -To properly understand how Python manages Unicode, you need to understand character processing. Computer files are written using a specific character set. A character set is a collection of characters used within a language or domain. For instance, the written English language maps to a character set containing 26 upper and lower case letters, along with punctuation marks. However, computers use a more formal collection called a *Coded Character Set* (CCS). - -In a CCS, each character is assigned a corresponding numerical value known as a *code point*. A set of code points makes it possible for a system to translate between the on-screen representation of each character and its binary equivalent. Every character set is also associated with a *code unit*. The code unit determines the size of each encoded character. For instance, a character set could encode every single character using 16 bits, or two bytes. The same code point could be associated with different code units in different encodings. For instance, the value `127` might be represented using 7, 8, 16, or 32 bits. Some formats even use a variable-length encoding. This means it is not possible to determine the binary representation of a character based on its code point. - -Text is decoded and encoded using a specific encoding standard. The encoding algorithm is known as a *codec*, which is a portmanteau of the coder/decoder. The system must know what codec to use to encode/decode the file correctly. Files can be decoded from bytes to characters and text can be encoded from characters to bytes. Format conversions can certainly become complicated, but most files use either the ASCII or Unicode format. - -## What is Unicode? - -Unicode is currently the most widely-used encoding standard. It was developed through the joint efforts of Xerox and Apple, but it is currently administered and maintained by the Unicode Consortium. Unicode has successfully unified pre-existing character sets and now serves as the international standard. Unicode has the goal of including every character used in the world's active writing systems. - -Unicode describes the list of available characters and their code points but does not describe how to map the code points to bytes. It also includes a formal Unicode name for each character. A variety of *character encoding schemes* (CES) can be applied to Unicode text to map the characters to bytes. - -The Unicode standard includes the following components: - -- **Character Repertoire**: This is the full set of characters that Unicode supports. Unicode currently defines nearly 150,000 characters. The repertoire is open to new additions, and additional characters are always being proposed. The characters are subdivided into several sub-components known as general categories. Some examples of general categories are `letter`, `mark`, `number`, and `symbol`. -- **Coded Character Set (CCS)**: Like other CCS systems, the Unicode standard maps each character to a code point. Each code point represents one and only one character. For instance, Unicode hexadecimal code point `1F6A6` represents the traffic light emoji 🚦. The Unicode code point for a given character can differ from the code points used in other systems, although all ASCII characters continue to use the ASCII code points. -- **Character Encoding Form (CEF)**: This component explains how to map code points to code units. -- **Character Encoding Scheme (CES)**: The encoding scheme maps code units to a sequence of bytes. It describes how to transmit files over a network and how to store character information in binary format. Unicode does not recommend a specific CES. Standards including UTF-8, UTF-32, or ISO/IEC 2022 can be used. However, UTF-8 is usually favored, mainly because it is more concise than the other systems. - -The Unicode character set includes all traditional ASCII characters, international writing scripts, symbols, and a large number of emojis. Unicode also contains various control and non-printable characters. Each Unicode letter is identified using the letter `U`, the `+` sign, and its code point. For example, the Unicode character having code point `639` is represented by the string `U+0639`. - -The Unicode code space is divided into seventeen planes to help structure and organize the collection. Related characters are placed within contiguous blocks inside a single plane. This makes it easier to locate specific characters in the published Unicode charts. All characters have a fixed name that uniquely identifies them. This name cannot be subsequently changed, even if it is inaccurate or contains errors. - -Unicode contains several unallocated "non-character" code points and blocks of private-use code points. The private characters can be used internally or through an agreement between a sender and receiver. In addition, a set of "formatting" characters modifies the behavior of adjacent characters, including ligatures. Some abstract characters can only be represented by a sequence of two or more characters. Unicode maintains a list of these abstract characters, but they are often the source of some confusion. - -Although moderated, Unicode is an open system. New additions are always being proposed. Unicode can expand to over one million code points, and there is still plenty of room for new characters. The current release of Unicode is 14.0, which was released in 2021. - -Most operating systems, web browsers, text processors, and programming languages such as Python have built-in support for Unicode. They can decipher Unicode-encoded text and display the appropriate characters. Some applications do not support Unicode or have not yet implemented the latest release. In this case, users might see empty rectangles or the `?` symbol in place of actual text. Some systems only support one or two-byte Unicode characters, which is a subset of the entire collection. - -The [Unicode site](https://home.unicode.org/) provides a complete overview of the Unicode standard, along with a FAQ and explanation of how to use the site. Perhaps the most important section of the site is the [specification of the latest release](https://www.unicode.org/versions/Unicode14.0.0/). The documentation allows developers to view the latest code charts and read an overview of each section. - -### What is the Difference between ASCII and Unicode? - -ASCII is a very early character encoding developed from telegraph code. It can be considered an ancestor of the current Unicode system. ASCII is an abbreviation of the American Standard Code for Information Interchange. It was the standard during the early days of the internet until approximately 2008 and is still common today. - -The ASCII character set consists of 128 characters, which have code points between 0 and 127. Each code point is represented as a 7-bit binary number. Some applications used the eighth and final bit for proprietary purposes, leading to a lack of compatibility. The set of ASCII characters was found to be too small and restrictive, so new encodings were developed to allow for more characters. However, most modern encoding systems are based on ASCII and typically preserve the original code points for the original ASCII characters. - -Within the ASCII character set, control characters and related characters, such as digits, have contiguous code points. This makes it easier to locate characters. The ASCII system consists of the following characters. - -{{< note >}} -All code points in this list use the decimal system. -{{< /note >}} - -- Lowercase letters from `a` to `z`. These have code points between `97` to `122`. -- Uppercase letters from `A` to `Z`. They are assigned code points between `65` to `90`. -- The digits `0` to `9`, run from code points `30` to `39`. -- The space character, with code point `32`. -- Essential punctuation points. -- Opening and closing brackets, parentheses, braces, chevrons, and forward/backward slashes. -- A small set of mathematical, typographical, and other symbols, including `+`, `&`, `$`, and `^`. -- A set of 32 non-printable control characters, including codes for a line return, tab, bell, backspace, and form feed. These characters have code points `1` to `31`, and `127`. Many of these codes apply to archaic printing devices and are no longer in use. A few of these codes have been assigned new meanings. -- A `null` character that has code point `0`. - -A complete list of the characters can be found on the [Wikipedia ASCII page](https://en.wikipedia.org/wiki/ASCII#Printable_characters). The ordering of characters based on their ASCII code points is known as *ASCIIbetical order*. Computer systems sometimes process characters using ASCIIbetical order rather than alphabetical order. - -By contrast, Unicode is an expanded and updated encoding standard that builds upon the original ASCII standard. Unicode separates the code points from the details of the encoding system. This permits a much wider range of characters up to four bytes. - -The Unicode character set incorporates the entirety of the ASCII character set as the first 127 characters. All ASCII characters have the same code points in both encodings. This means any ASCII text file is a valid UTF-8 file. Additionally, any UTF-8 file that only uses ASCII characters can be processed as ASCII text. This ensures legacy ASCII-only applications can accept files with only ASCII characters, maintaining backward compatibility. - -The greater flexibility of Unicode allowed it to become the modern standard for character encoding in computer systems and on the internet. However, ASCII-only applications and systems persist to this day. ASCII-only applications and files are guaranteed to be compatible with any system. - -### What is UTF-8? - -UTF-8 is one of several character encoding schemes implementing the Unicode encoding standard. An encoding scheme translates a string to a byte sequence and a byte sequence back into a string. UTF-8 is defined in [RFC 3629](https://datatracker.ietf.org/doc/html/rfc3629). It is capable of encoding all 1,112,064 code points in Unicode. - -UTF-8 is backward-compatible with ASCII. All ASCII files are UTF-8 compliant and a UTF-8 file that only contains ASCII characters is compatible with ASCII systems. - -A code unit in UTF-8 is 8 bits, compared to 7 bits for ASCII. However, one character can map to anywhere between one and four code units. The alternative UTF-32 codec represents all characters using four code units each consisting of four bytes. This means UTF-8 generates much smaller files than UTF-32. - -UTF-8 is the most popular encoding on the internet and is used in between 95 to 100% of all websites. It is now considered the international standard for Unicode encoding. Virtually all modern applications support UTF-8, and many standards and applications only accept files encoded in UTF-8. UTF-8 files are safe to use with programming languages that use escape or special characters. - -Here are some of the main advantages of UTF-8: - -- UTF-8 can encode all possible Unicode code points. -- It only uses a byte containing all zeroes to represent the `null` character. This maximizes interoperability with the C programming language and legacy protocols that use `0` to indicate the end of a file. -- All ASCII strings are valid UTF-8 strings and have the same code points. This means UTF-8 can encode ASCII files. Seven-bit values never otherwise occur in UTF-8, avoiding confusion. -- UTF-8 is a compact and concise encoding. Most Unicode characters can be stored in one or two bytes. -- UTF-8 can resynchronize at the next code point to recover from corrupted or lost data. Because certain values cannot occur in UTF-8, errors are easier to detect. The start of a character can be found within three bytes of any point in the file, and the sequence for one character never begins inside another character. -- It avoids the bytes `FF` or `FE`, to avoid confusion with the UTF-16 byte order mark. This means it is impossible to misinterpret a UTF-8 file as UTF-16. -- It is byte-oriented and the encoding does not depend on the underlying hardware architecture. The first byte indicates the number of bytes of the next character. -- If a file gets split in the middle of a character, only a single character is lost. - -The Unicode encoding process follows an establishing encoding formula, which designates certain bits as framing bits. In practice, this restricts the maximum value to 21 bits. The encoding technique can be described as follows. - -- One-byte values begin with a `0`, followed by the 7 bits of the code point. All ASCII values, and only the ASCII values, are encoded as one-byte values. -- For two-byte values, the first byte begins with `110`, and the second with `10`. A byte beginning with `10` is a *continuation byte*. The remainder of the bits encodes the code point. These values are used for all Latin-style alphabets, along with Greek, Cyrillic, Hebrew, Arabic, and some other languages. Two-byte values also encode diacritical marks and International Phonetic Alphabet (IPA) extensions. -- Three-byte values start with `1110`. The second and third bytes begin with `10`. This plane of values encodes the Basic Multilingual Plane, including almost all characters commonly in use, and many emojis. -- Four-byte values are indicated with leading `11110` bits. The remaining three bytes start with `10`. Emojis, mathematical symbols, and some ideographic symbols from Asian languages are encoded using four bytes. -- Certain bit patterns indicate an invalid sequence. This could indicate a potentially valid code point that has not been assigned a value yet or an invalid UTF-8 value. An example is an unexpected continuation byte. Most invalid values are dropped, but hackers have used them to bypass security measures. -- The byte order mark `0xEF 0xBB 0xBF` at the start of a file indicates the file uses UTF-8. However, it is not recommended or required and might confuse some systems. If the file begins with the byte order mark `FEFF`, the file is encoded in UTF-16, not UTF-8. - -As an example, here is how to encode the Unicode code point for the Peso symbol `₱`. - -- The Unicode code point for this symbol is `0x20B1`. It can be found in the currency chart in the [Unicode charts](https://www.unicode.org/charts/). -- This value requires a three-byte encoding, with 16 bits used for the code point and eight bits for the framing. -- Converted to binary, this value is `0010 0000 1011 0001`. -- The first four bits are encoded in the first byte and preceded by the framing bits `1110`. This results in `1110 0010`. -- The second byte begins with `10`, followed by the next six bits of the code point. This results in `1000 0010`. -- The third and final byte also starts with `10`, followed by the remaining encoding bits. This yields `1011 0001`. -- Taken together, this is `1110 0010 1000 0010 1011 0001`. In hexadecimal, this is `0xE282B1`. - -UTF-8 can be contrasted with the UTF-16 and UTF-32 encoding schemes. UTF-16 always uses at least two bytes to encode characters. It can also use four bytes, while UTF-32 always uses four bytes. These schemes are somewhat easier to decode and use fewer framing bits. However, they are less concise than UTF-8 and are not ASCII-compatible. - -## How Does Python Implement Unicode? - -Python handles Unicode very differently in Python 2 and Python 3. In Python 2, the default encoding is ASCII. But in Python 3, UTF-8 is the default. This makes text processing much easier than before. It is no longer necessary to declare the encoding in the first or second line of the file. Nor is it necessary to preface Unicode strings with `u`. - -{{< note >}} -This guide only discusses Unicode processing for Python 3. Python 2 handles Unicode very differently, so these instructions do not apply. For more information, consult the [Python 2 Unicode documentation](https://docs.python.org/2/howto/unicode.html) for further guidance. Python strongly recommends that developers upgrade to Python 3. -{{< /note >}} - -According to the Python [Unicode documentation](https://docs.python.org/3/howto/unicode.html), the most important principle is to only work with Unicode strings internally. Decode the input data as soon as possible and encode the output only at the end. This greatly simplifies most programs and avoids introducing errors. - -All Python 3 strings are Unicode strings and are stored as Unicode. This means Unicode characters can be included in a string. When the text is encoded, all characters are converted to their byte equivalent. To use Unicode characters in a string, declare the string normally, and include the Unicode characters in the correct position. - -```file -u = "❤️" -print(u) -``` - -```output -❤️ -``` - -Python 3 also permits many Unicode characters to be used as part of variable and function names. However, symbols or emojis can't serve in these roles. For instance, the "heart" emoji can not be part of a variable name. In the following example, the variable name `Øyen` contains a character from the Norwegian alphabet. - -```file -Øyen = "Lofoten" -print(Øyen) -``` - -```output -Lofoten -``` - -A string can still be declared using a `u` at the front of the string, but this is no longer required. If a developer is simultaneously processing Unicode and ASCII files, they might want to use this convention to increase clarity. This is also necessary to backport files to Python 2. - -```file -u = u"❤️" -``` - -A character can also be declared using its *escape sequence*. The Unicode escape sequence for two-byte characters is a backslash `\` character, a `u`, and four hexadecimal digits indicating the code point. If the hexadecimal character is shorter than four digits, insert leading zeros to pad the length to four. - -The Unicode code point for the musical note symbol `♩` is `0x2669`. This symbol can be assigned to a Python string using its hexadecimal equivalent. - -```file -x = "\u2669" -print(x) -``` - -```output -♩ -``` - -The escape sequence for a Unicode character requiring three or four bytes begins with `\U`. The hexadecimal value must contain eight digits, so pad the front of the value with zeros until it is the proper length. - -For example, the Unicode bumblebee emoji is encoded in a three-byte format possessing the Unicode code point `U+1F41D`. To assign this emoji character to a variable using its escape sequence, pad it out to `0001F41D`. After the character is assigned to a string, it can be printed out using the Python `print` function. - -```file -bee = "\U0001F41D" -print(bee) -``` - -```output -🐝 -``` - -### Using the Python `unicodedata` Library - -Python provides many additional functions and libraries to help developers work with Unicode. The most relevant library is `unicodedata`. It allows developers to extract more information, such as the official name or code point, about each Unicode character. This library can be imported using the following Python directive. - -```file -import unicodedata -``` - -To find the code point of a Unicode character, use the `ord` function. Precede the character with a `u`. This example demonstrates how to determine the code point for the musical note symbol. - -{{< note >}} -This function only returns valid results for Unicode characters with a single code point. Although `ord` is a core Python function, the `unicodedata` library is necessary to determine multi-byte mappings. -{{< /note >}} - -```file -print(ord(u"♩")) -``` - -```output -9833 -``` - -The opposite function of `ord` is `chr`. It is used to convert the decimal integer of a code point to the actual character. - -```file -print(chr(9833)) -``` - -```output -♩ -``` - -The `name` method is used to retrieve the official Unicode name for any Unicode character. - -```file -print(unicodedata.name(u"🐝")) -``` - -```output -HONEYBEE -``` - -The official Unicode name can also be used to determine the character. Pass the official name, including all spaces, to the `lookup` method. - -```file -print(unicodedata.lookup("QUARTER NOTE")) -``` - -```output -♩ -``` - -A character can also be assigned to a string using its official Unicode name. Enclose the name in braces and precede it with a backslash and `N`. The following example assigns the musical note symbol to the `note` string. - -```file -note = "\N{QUARTER NOTE}" -print(note) -``` - -```output -♩ -``` - -### Reading and Writing Unicode Files in Python - -The same concepts are used to read a file containing Unicode characters. Declare the file encoding as `utf-8` when calling the `open` function. Read the file normally. - -```file {title="read_unicode.py"} -with open('sample.txt', encoding='utf-8') as f: - for line in f: - print(repr(line)) -``` - -Given a `sample.txt` file containing some of the Unicode characters used in this guide, `read_unicode.py` returns the following results. - -```output -'Øyen\n' -'♩\n' -'❤️\n' -'🐝\n' -``` - -For a write operation, create the file object as follows. Ensure the encoding is set to `utf-8`. The `write` method can accept Unicode characters or code points preceded by `\u` or `\U`. - -```file {title="write_unicode.py"} -with open('sample.txt', encoding='utf-8', mode='w') as f: -``` - -For more information on reading and writing Unicode files, consult the [Python Unicode documentation](https://docs.python.org/3/howto/unicode.html). - -### Limitations - -Python 3 has far fewer limitations than Python 2. However, certain functions might not work as expected for characters requiring more than one code point or interactions between two consecutive characters. A good example of this is the `ord` function, which expects a single code point. - -Always confirm the encoding of an input file unless it is known to be a UTF-8 file. Usually, the file specifies the encoding in the first or second line. However, sometimes the codec is not clear, so developers might have to contact the file originator. - -### Encoding Text in Python - -Encoding and decoding is the process of converting from strings to bytes. Strings display the text in a human-readable format, and bytes store the characters as binary data. Encoding converts data from a character string to a series of bytes. Decoding translates the bytes back to human-readable characters and symbols. It is important not to confuse these two methods. `encode` is a string method, while `decode` is a method of the Python byte object. It is not possible to encode bytes because the bytes are already encoded. Likewise, it is not possible to decode a string. A string is already a series of characters and it technically does not have any encoding. The string object does not even have a `decode` method. Attempting to call `decode` for a string results in an error. - -To use Python to encode Unicode characters, use the string `encode` method. The default encoding standard is UTF-8, but for reasons of clarity, it is good practice to always explicitly pass in the protocol. The following example demonstrates how to encode the musical note Unicode character. Python converts the Unicode string to bytes and returns an encoded byte object. - -```file -note = "♩" -note.encode("utf-8") -``` - -```output -b'\xe2\x99\xa9' -``` - -The `encode` method works the same way on multi-character strings. The ASCII characters are not converted to bytes. This preserves backward compatibility with ASCII-only applications. - -```file -greeting = "Have a nice day! ♩" -greeting.encode("utf-8") -``` - -```output -b'Have a nice day! \xe2\x99\xa9' -``` - -### Decoding Unicode Bytes in Python - -The inverse function to `encode` is `decode`. If this function is applied to a sequence of bytes, it returns the equivalent Unicode string of characters. To decode a function, use the `decode` method of the byte object. The encoding protocol is assumed to be UTF-8 by default, but it is safer to explicitly state it. This example decodes the byte encoding for the note character back into a string. - -```file -notebytes = b'\xe2\x99\xa9' -notebytes.decode("utf-8") -``` - -```output -'♩' -``` - -## Common Unicode Errors in Python - -Most of the time, the encoding and decoding process goes smoothly without much extra effort. However, Unicode errors can occur in Python. When Python cannot decode a file, it displays the `UnicodeDecodeError` message. - -The most common Python Unicode error happens when a non-UTF-8 file is decoded using the UTF-8 codec. In this example, a string is encoded using the `latin-1` encoding. Attempting to decode it as a UTF-8 file results in a `UnicodeDecodeError`. - -```file -quartercup = "¼" -quart_encode = quartercup.encode("latin-1") -quart_encode.decode("utf-8") -``` - -```output -UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbc in position 0: invalid start byte -``` - -To decode this string properly, declare it as a `latin-1` file in the function call. The type of encoding is often specified in the first line of the file. Python searches for the keywords `coding: name` or `coding=name`. But the convention is to use the format `# -*- coding: latin-1 -*-`, a carryover from the emacs editor. - -```file -quart_encode.decode("latin-1") -``` - -```output -'¼' -``` - -This error can also occur when the `decode` method is applied to a byte object containing invalid Unicode sequences. This can happen if the file was corrupted or the characters were not encoded correctly. In this example, the `0xfe` byte is assigned to a Python byte object. This character is not permitted anywhere in a UTF-8 file because `xfe` is reserved for the UTF-16 byte order mark. If this byte is decoded using the UTF-8 decoder, Python raises an error. - -```file -junk_bytes = b'\xfe' -junk_bytes.decode("utf-8") -``` - -```output -UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfe in position 0: invalid start byte -``` - -The `UnicodeEncodeError` is less common because developers generally have some control over the material they are decoding. However, it can happen if a developer attempts to encode Unicode data using another encoding algorithm. In this case, encoding is used on a string containing the bumblebee emoji. The string can be correctly converted to bytes using the UTF-8 encoder. However, when `encode` is invoked with the `ASCII` encoder, the attempt fails, generating the `UnicodeEncodeError`. This is because the bumblebee emoji does not exist in ASCII, and the ASCII codec cannot translate the Unicode code point. - -```file -bee = "\U0001F41D" -utf8_bee = bee.encode("utf-8") -ascii_bee = bee.encode("ascii") -``` - -```output -UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f41d' in position 0: ordinal not in range(128) -``` - -{{< note >}} -This UTF-8 codec permits unassigned Unicode code points to be encoded to bytes. However, these byte objects cannot later be decoded back into characters. -{{< /note >}} - -To avoid errors, `encode` and `decode` accept the `replace` keyword as the second parameter. This substitutes the Unicode replacement character, `U+FFFD` for any character that cannot be properly translated. The `ignore` keyword completely ignores unknown characters. However, most developers prefer to avoid silent errors and receive an indication something has gone wrong. - -```file -junk_bytes = b'\xfe' -junk_bytes.decode("utf-8", "replace") -``` - -```output -'�' -``` - -## Concluding Thoughts About Unicode on Python - -Unicode was designed as a replacement and extension for the ASCII character set, which only contained 128 characters. Unicode covers characters from almost every world language, along with many symbols and emoji. Each character has an equivalent code point, which is used to identify, display, and translate the character. - -UTF-8 is an encoding technique for converting Unicode characters to bytes and vice versa. It uses between one and four bytes to store a Unicode code point and is fully backward-compatible with ASCII. Python fully supports both Unicode and UTF-8 and permits strings to include any Unicode character. It includes the `unicodedata` library, which allows Python to manipulate Unicode data. Python decodes and encodes Unicode data using built-in string and byte methods. For more information on using Unicode in Python, see the [Python documentation](https://docs.python.org/3/howto/unicode.html). diff --git a/docs/guides/development/python/pros-and-cons-of-python/index.md b/docs/guides/development/python/pros-and-cons-of-python/index.md deleted file mode 100644 index 36cd0afd9ec..00000000000 --- a/docs/guides/development/python/pros-and-cons-of-python/index.md +++ /dev/null @@ -1,112 +0,0 @@ ---- -slug: pros-and-cons-of-python -title: "The Pros and Cons of Python Programming" -title_meta: "A Programmers’ Guide to Python: Advantages & Disadvantages" -description: 'As with any programming language, there are pros and cons of Python. Read our guide to find out whether you can benefit from learning Python. Click here!' -authors: ["Jeff Novotny"] -contributors: ["Jeff Novotny"] -published: 2022-03-23 -keywords: ['benefits of python','pros and cons of python','python advantages','disadvantages of python'] -license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)' -external_resources: -- '[Python.org web site](https://www.python.org/)' -- '[Python documentation](https://docs.python.org/3/contents.html)' -- '[Python Package Index (PyPI) repository](https://pypi.org/)' -- '[Python Beginner Guide](https://wiki.python.org/moin/BeginnersGuide)' -- '[Python downloads page](https://www.python.org/downloads/)' -- '[Django](https://www.djangoproject.com/)' -- '[Flask](https://flask.palletsprojects.com/en/2.0.x/)' -- '[TensorFlow](https://www.tensorflow.org/)' -- '[PyTorch](https://pytorch.org/)' -- '[NumPy](https://numpy.org/)' -- '[SciPy](https://scipy.org/)' -- '[Python licensing site](https://docs.python.org/3/license.html)' ---- - -[Python](https://www.python.org/) is currently one of the world's most popular programming languages. It achieved this position due to its powerful features, flexibility, and ease of use. This guide explains the pros and cons of Python and compares it to other languages. It also discusses the situations where Python is one of the best alternatives. - -## What is Python? - -### The History of Python - -Python is an open source, general purpose programming language. Guido van Rossum developed Python based on the defunct ABC programming language and named it after the Monty Python comedy troupe. Python was designed to be simple, readable, and highly extensible through the use of modules. The first version of Python was released in 1991, and the more fully featured Python 2.0 followed in 2000. Both releases have since been discontinued. - -Python 3.0 was introduced in 2008, but is not compatible with earlier releases. Even though Python included the `2to3` upgrade utility, this decision was highly controversial and created significant issues for the user base. Because the transition was so difficult, there is unlikely to be a release 4 of Python. Instead, new minor releases are planned for each year. The Python Software Foundation currently administers Python, and they continue to work on new features and ongoing performance improvements. - -Python continues to increase in popularity and is now ranked as one of the top five languages. It is widely used in data science, machine learning, artificial intelligence, and server & web applications. Many web developers use Python alongside external frameworks, including [Django](https://www.djangoproject.com/) and [Flask](https://flask.palletsprojects.com/en/2.0.x/), or third-party libraries. These frameworks include ready-to-use components and are especially useful for web development. - -### The Main Characteristics of Python - -Python uses many of the same concepts, commands, and control structures as other traditional programming languages. But it is different in many respects, and can almost be considered a new programming paradigm. Python promotes flexibility and clear coding design, and code adhering to its principles is said to be "Pythonic". Here are some of Python's main characteristics. - -- **Python is a High-Level Language**: High-level languages are more readable. They use meaningful variable names, and have meaningful syntax. No understanding of the underlying operating system is required. In this respect, Python is similar to other programming languages, including JavaScript, Rust, and C++, but is even more clear and legible. At the opposite end of the spectrum is assembly language. Assembly code refers to memory addresses and uses machine language instructions. -- **Python Supports Object-Oriented Programming (OOP)**: Python is an OOP language with support for classes, methods, inheritance, and encapsulation. Unlike Java, Python does not enforce an OOP model and object-oriented design principles are strictly optional. So it is possible to use Python strictly in imperative/procedural mode for short programs and simple utilities. Python now incorporates some features from the functional programming paradigm, but it is not considered a true functional programming language. -- **Python is a General-Purpose Language**: Domain-specific languages are intended for one specific purpose. For example, SQL is only used to communicate with relational database systems. However, Python is a general-purpose language, and has a wide range of applications. -- **Python is an Interpreted Language**: Unlike many languages, developers do not have to compile Python into assembly or machine code. When a developer completes a program, they can immediately run it with no intermediate steps. The Python interpreter deciphers each line at run time and executes it. This is different from languages like C/C++, which must be pre-compiled first. Python does have a compilation stage, but it takes place at run time and is hidden from the user. Python compiles a program down to low-level *bytecode* for the *Python Virtual Machine* (PVM) to interpret and execute. -- **Python is Dynamically-Typed**: Variables do not have to be assigned a type, such as "integer", when they are first used. Python determines the type of variable at run time. Python uses a technique known as "duck typing". It assigns a type to a variable depending on its value and how it is used. Python allows a variable to change type dynamically over the duration of the program. -- **Python Programs are Platform-Independent**: Because Python programs are interpreted, they can be ported to any platform. Only the Python Virtual Machine is platform-specific. It translates the Python code into valid machine code for the platform it is running on. - -## Pros and Cons of Python - -Python is a very distinctive language that has both pros and cons. It is great for certain situations and not as good for others. This section highlights both the advantages and disadvantages of Python. - -### Advantages of Python - -Python has become widely used and well liked due to a cluster of positive attributes. Here are some of the benefits of Python. - -- **Ease of Use**: Python has a simple, concise, and straightforward syntax. A Python program looks a lot like plain English and is highly readable. This makes Python programs easy to read and debug. Python's control structures are intuitive and easy to use. In addition, Python is dynamically typed, so there is no requirement to declare the type of each variable. For these reasons, Python is one of the most efficient and productive languages. -- **Gentle Learning Curve**: Python is one of the simpler languages to learn and is a good option for people learning to program. Programmers switching to Python from languages like C or Java can quickly reach peak efficiency. The Python package contains a useful *Integrated Development and Learning Environment* (IDLE). -- **Versatility**: Python is a flexible, general purpose language that fully supports both procedural and object-oriented programming. Due to its built-in and third-party packages, it is suitable for a wide range of tasks. It is dominant in the areas of data science and machine learning. It is also widely used for back-end web development and the *Internet of Things* (IoT). Even when it is not the best choice for a particular task, it is usually still a viable option. In addition, Python code can be embedded into projects written in other languages, such as C++, and code from other languages can be embedded in Python. -- **Efficient for Rapid Development**: Because Python is easy to use and does not have to be compiled, programs take less time to develop. Python programs are typically much shorter than equivalent programs in other languages. It is a great choice for quickly constructing prototypes in a rapid software development environment. -- **True Portability**: A huge Python advantage is that it can be written once and run anywhere. Python does not have to be compiled in advance, so users run a true Python program and not a Python executable. The program is not compiled until it is run, using the platform-specific PVM. This means any Python program can potentially run on any system that supports Python. -- **No Compile Process**: Python is an interpreted language and programs are automatically compiled at run time. A program can be run as soon as it is written. There is no separate compiler, no time-consuming compilation step, and no opaque compiler errors. Python programs are easy to write, debug, and change incrementally. -- **Automatic Memory Allocation**: Python does not have pointers and developers do not have to assign free space in memory. Python allocates memory automatically and a garbage collector recycles memory from discarded objects. This means developers do not have to worry about scribblers, memory leaks, invalid pointer references, or the size of each object. -- **Extensive Built-In Objects and Libraries**: Python has a large number of built-in compound objects including lists, sets, and record-like dictionaries. Each of these objects provides a collection of methods allowing for easy processing. In addition, Python has an extensive library containing tens of thousands of functions. These packages can be used for network communications, web integration, data processing, and hardware interactions. This makes it much faster to write programs because so many of the necessary routines have already been written. -- **Third-Party Library Availability**: In addition to Python's extensive built-in library, developers can access many free external libraries. These third-party libraries are easy to import and install using Python's `pip` package manager. Packages can be downloaded from the [Python Package Index (PyPI) repository](https://pypi.org/). PyPI also allows developers to publish their own packages. -- **Open Source and Free to Use**: All Python releases are available for free under an open source license. Python can even be modified and re-distributed at no cost. This greatly reduces development costs. For more information about Python licensing, see the [Python documentation site](https://docs.python.org/3/license.html). -- **Large User Base**: Python has a large, active, and passionate community of users. It is easy to find learning materials and other resources, ask questions, search for jobs, hire additional developers, and meet other Python programmers. - -### Disadvantages of Python - -Despite its many advantages, Python also has a few notable disadvantages. Here are some of the drawbacks of Python. - -- **Not Very Fast**: Python is much slower than more efficient languages like C and Java. Python is interpreted and dynamically-typed, so the run-time compiler has a lot of work to do. It must constantly validate the type of each variable. This means Python is not the best choice for scenarios where speed is critical. -- **Memory Intensive**: Python is not optimized to reduce memory. It can use ten times the RAM as a program written in a more frugal language. However, this is partly a tradeoff in return for flexibility and ease of use. In addition, the Python garbage collector cannot gather all discarded resources immediately, which reduces the amount of available memory. Python is not a good choice for memory-constrained environments. -- **Harder to Avoid Runtime Errors**: Python is not compiled until runtime and is dynamically typed. Therefore, many problems that would otherwise be caught by the compiler do not appear until the program runs. This might include something as simple as a syntax error, but it can include problems like trying to add an integer and a string together. -- **Not Much Traction in Mobile or Desktop Applications**: Because it is somewhat slow and uses a lot of memory, Python has not made gains in the mobile space. There are some Python development tools for mobile apps, but they are more limited than frameworks for other languages. The situation is a bit better in client desktops, but Python is still not too popular for front-end applications. -- **Not Optimized for Database Access**: It is more difficult to work with databases in Python than in some other applications. Python lacks a powerful, high quality, easy-to-use interface like the Java Database Connectivity (JDBC). It can still be used if the database reads and writes are relatively straightforward. But it is not the best choice for applications that have complex interactions with a large corporate database. -- **No Multithreading Support**: Due to its architecture, Python does not support multi-threading. Instead, it uses multiprocessing, where each "thread" runs in a separate Python process. This relies on the oversight of the operating system to schedule and balance the processes, and might not deliver equally good results. -- **Prone to Overuse or Misuse**: Python's simplicity is one of its strengths, but this can be a surprising weakness in some situations. Because it is so easy to use, it is often misused for tasks where it is not one of the best alternatives. Python is great for rapid development and prototypes, but this might tempt organizations to overlook proper software development principles. - -## Should You Learn Python? - -After reading about the pros and cons of Python, you might still be uncertain whether it is worth learning. On one hand, there are always benefits to learning a new language. But there are at least a dozen other popular languages, so there are also opportunity costs. - -Nonetheless, there are some situations where Python is the right choice. There are benefits to learning Python if any of the following statements apply. - -- **You are Using Agile Development**: Python is simple and concise, and it can be used to quickly work out a proof of concept or a trial prototype. Python's extensive library reduces the number of helper functions to write. It is easy to be fast and productive in Python. -- **You Work in Data Science or AI**: Python is especially strong in the areas of data science and machine learning. There are many external libraries available for these areas and a strong user base. For machine learning or natural language processing, [TensorFlow](https://www.tensorflow.org/) and [PyTorch](https://pytorch.org/) can be used. [NumPy](https://numpy.org/) and [SciPy](https://scipy.org/) are frequently used for data science or scientific computing. -- **You Require Portable Tools**: Python is a sensible choice for multi-platform utilities. Python is available for Linux, Windows, MacOS, and other popular platforms. It is compiled at run time, so the program can run anywhere on an interpreter optimized for the underlying operating system. -- **You Require Test Automation or DevOps Scripts**: Python is great for scripting because it is so quick and easy to write, modify, and debug. Speed and memory use are typically not of much concern in a QA environment, so there are no real downsides. Python has a built-in test library named [PyUnit](https://wiki.python.org/moin/PyUnit). PyUnit integrates smoothly with most test frameworks including `pytest`. On the DevOps side, Python forms the backbone of many configuration management programs. -- **You Require a Back-End for Web Applications**: Along with the popular Flask or Django frameworks, Python can provide the server-side engine for web applications. The frameworks provide libraries and templates for most web design tasks. -- **You Want a Free and Open Source Language**: Python is free to download, use, and modify under a versatile open source license. Python reduces development costs and makes it easy to upgrade to new releases. -- **You Want a Fun and Easy to Learn Language**: Python has an easy and straightforward syntax. It is a great choice for beginners who are learning how to program. It is also advantageous for professionals who want to dive into development without worrying about fussy programming details. Python's extensive libraries allow developers to solve problems at a high-level without writing complex low-level routines. -- **You Want a Large Developer Community**: Python is one of the most popular general-purpose languages. It is versatile and used in a wide number of specialties, so companies are always looking for developers. Google, Facebook, Microsoft, Spotify, Instagram, and Uber all use Python for at least some applications. Python is also a popular development language in start-ups. - -It is easy to start using Python. A good place to begin is the [Python Beginner's Guide](https://wiki.python.org/moin/BeginnersGuide). The Python Wiki also has a list of tutorials and resources for [New](https://wiki.python.org/moin/BeginnersGuide/NonProgrammers) or [Experienced Programmers](https://wiki.python.org/moin/BeginnersGuide/Programmers). - -To run Python on Ubuntu or another Linux distribution, use the command `python3`. Python is usually already installed on most Linux systems. To download Python for other platforms, see the [Python downloads page](https://www.python.org/downloads/). For more information about how to use Python on a Linode system, see the [Linode guide to Python](/cloud/guides/how-to-install-python-on-ubuntu-20-04). - -### Alternatives to Python - -For situations where Python is not the best choice, consider the following options. - -- **C/C++**: These two languages are strong choices when speed, performance, and low memory use are important. They are statically typed and require pre-compilation, so they generate fewer runtime errors. They are often used in game development and embedded systems. Unfortunately, they are considered difficult languages to master. -- **JavaScript**: Like Python, JavaScript is an interpreted and dynamically-typed language. However, it is the most common language for interactive web pages. JavaScript runs on the client side, and interacts seamlessly with HTML and CSS components. It can be used alongside Node.js for full stack web development. Python is not typically used on the front end, so it is not a good full stack alternative. -- **R**: R is an alternative to Python for data science. However, it is more geared toward statistical analysis. R is particularly good for data visualization, but it is more complicated and difficult to learn. Python is a simpler and faster option for general purpose data and numerical analysis and has better machine learning capabilities. - -## A Summary of the Pros and Cons of Python - -This guide discusses the pros and cons of Python, which is more effective in some situations than others. Python is an interpreted, statically-typed programming language that allows both object-oriented and procedural programming. Some of the main benefits of Python include its ease of use, concise and straightforward syntax, and vast libraries. Other Python advantages are its portability, versatility, large user base, and free & open source license. - -Some of the disadvantages of Python include its slow speed and heavy memory usage. It also lacks support for mobile environments, database access, and multi-threading. However, it is a good choice for rapid prototyping, and is widely used in data science, machine learning, and server-side web development. For more information about Python, see the [official Python site](https://www.python.org/). \ No newline at end of file diff --git a/docs/guides/development/python/python-get-current-directory/index.md b/docs/guides/development/python/python-get-current-directory/index.md deleted file mode 100644 index f08d7c7604a..00000000000 --- a/docs/guides/development/python/python-get-current-directory/index.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -slug: python-get-current-directory -title: "How to Get the Current Directory in Python" -title_meta: "A Guide to Paths in Python: Get Working Directory" -description: 'This guide provides information on how to retrieve the current working directory in Python using the os module. It covers the os.getcwd() function and provides sample code to demonstrate its usage.' -authors: ["Martin Heller"] -contributors: ["Martin Heller"] -published: 2023-06-12 -keywords: ['python change working directory', 'python get current directory', 'python change directory', 'change directory python'] -license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)' ---- - -Programs often need to look for, read, and write specific files in a special location. By convention, and with support from the operating system, programs maintain a current working directory used as the context for many of their files. There may also be fixed directories and files that are special to the program, such as the configuration files for editors and IDEs. - -## What is the Current Working Directory? - -In most operating systems, a directory is a container for files, and possibly for other directories, called subdirectories. In Unix-like systems, directories are treated as a special kind of file. - -Files contain data and/or code. In Unix-like systems, files can have special bits in their permissions that mark them as executable. In Windows systems, the file type determines whether a file is executable. - -Folders might seem like they are synonymous with directories, but they are usually considered the graphical representation of directories rather than the directories themselves. Paths are strings that describe the locations of directories and files in the context of the operating system’s file system. Paths can be absolute, or relative. - -The current working directory (CWD) associates a specific directory with a program and makes that directory the default location for all file operations. When a program reads or writes a file without specifying a directory in the path, it looks for the file in the current working directory. If the program specifies a relative path, such as `../my_file`, the path is calculated relative to the current working directory, in this case specifying the directory above the CWD. If the program specifies an absolute path, such as `/usr/bin/python3`, the CWD does not enter into the calculation of the location. - -The current working directory is independent of the executable file’s location. - -## How to Get and Change the Current Directory in Python - -Python programs share the operating system’s idea of the CWD with all other programs, even though Python as a whole is a system-agnostic language. Python has a module, `os`, that provides a portable way of using operating system-dependent functionality, and within that module, each system’s version of Python has an appropriate implementation for that system. - -### How to Get the Current Working Directory - -To get the current working directory in Python, import the `os` module and call the `os.getcwd()` method. Here’s an example: - -```output -Python 3.9.7 (default, Sep 3 2021, 09:29:02) -[GCC 9.3.0] on linux -Type "help", "copyright", "credits" or "license" for more information. ->>> import os ->>> cwd = os.getcwd() ->>> print(cwd) -``` - -In the example above, the `os.getcwd()` method returns a string representing the current working directory. - -### How to Change the Current Working Directory - -To change the current working directory in Python, import the `os` module and call the `os.chdir(
Welcome to your own Nginx website!
- - - ``` - -1. Add a `Dockerfile` to the image directory with the file the contents shown here. This file defines your Docker image. - - ```file {title="Dockerfile" lang="docker"} - FROM nginx:latest - RUN rm /etc/nginx/conf.d/default.conf - COPY nginx-default.conf /etc/nginx/conf.d/default.conf - COPY html /usr/share/nginx/html - ``` - -1. Use the Docker `build` command to build an image from the Dockerfile. This example gives the image the name `example-nginx-image`. - - ```command {title="Your workstation"} - sudo docker build -t example-nginx-image . - ``` - -1. You can now verify that the image has been successfully created by listing your Docker images: - - ```command {title="Your workstation"} - sudo docker images - ``` - - ```output - REPOSITORY TAG IMAGE ID CREATED SIZE - example-nginx-image latest 123658fe84af 5 seconds ago 142MB - ``` - -{{< note >}} -You can learn more about building Docker images through our guide on [How to Use a Dockerfile to Build a Docker Image](/cloud/guides/how-to-use-dockerfiles). -{{< /note >}} - -#### Push an Image to Harbor - -With a Docker image built and ready, you can use the Docker CLI to push that image to your Harbor registry: - -1. Because the Harbor project is private, you need to log in to the registry from the Docker CLI: - - ```command {title="Your workstation"} - sudo docker login harbor.example.com - ``` - - This prompts you for a username and password. Use the `admin` credentials used to log in to the Harbor interface (use the new password you set after logging in for the first time). - -1. Add a tag to your Docker image. In the example below, the image is tagged with a version number `1.0.0`. Notice that the image is tagged for the `library` project within the Harbor registry. - - In this command, replace `harbor.example.com` with your Harbor server's domain. - - ```command {title="Your workstation"} - sudo docker tag example-nginx-image harbor.example.com/library/example-nginx-image:1.0.0 - ``` - -1. Push the Docker image up to your Harbor registry. In this command, replace `harbor.example.com` with your Harbor server's domain. - - ```command {title="Your workstation"} - sudo docker push harbor.example.com/library/example-nginx-image:1.0.0 - ``` - - ```output - The push refers to repository [harbor.example.com/library/example-nginx-image] - [...] - 1.0.0: digest: sha256:f37ae9e729f7c3a0d5f8e84e8dcfc019093ac76b48e885568c8c5b6b163d5b43 size: 2191 - ``` - -You can go to the Harbor dashboard in your browser to see the results. Navigate to the **Projects** page using the menu on the left, and select the **library** project from the listing. You should see your image listed. - -[](harbor-project.png) - -## How to Use the Harbor Registry with LKE - -Harbor can act as the image registry for a Kubernetes cluster. The steps in this section show how to deploy the example Docker image in the previous section from your Harbor registry to your LKE cluster. - -1. Provision an LKE cluster. Follow our [Linode Kubernetes Engine - Get Started](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-lke-linode-kubernetes-engine) guide to install the kubectl tool on your local workstation, deploy a cluster, and download your cluster's kubeconfig. The new cluster should have a node pool with three nodes. The nodes can have minimal specifications, because they are only used to serve a small website. - - The commands in the next steps should be run from your workstation. - -1. Create a secret with kubectl. This secret allows your cluster to have an authenticated connection to your private Harbor registry. - - Replace the `--docker-server` URL with your Harbor server's URL. Replace the `--docker-password` value with the credentials for your Harbor server. - - ```command {title="Your workstation"} - kubectl create secret docker-registry harbor-registry-secret --docker-server="https://harbor.example.com" --docker-username="admin" --docker-password="Harbor12345" - ``` - -1. Create an `example-nginx-deployment.yml` file with the contents shown here. This configuration deploys the `example-nginx-image` custom image alongside a service for accessing the containers. - - This deployment uses three `replicas`. You can adjust that number to match the number of nodes in your LKE cluster on **line 18**. - - **Line 29** refers to the URL of your image on the Harbor server. Update the domain for this URL to match your Harbor server's domain. - - ```file {title="example-nginx-deployment.yml" lang="yml" hl_lines="18 29"} - apiVersion: v1 - kind: Service - metadata: - name: example-nginx-service - spec: - type: NodePort - selector: - app: example-nginx - ports: - - port: 80 - targetPort: 80 - --- - apiVersion: apps/v1 - kind: Deployment - metadata: - name: example-nginx-app - spec: - replicas: 3 - selector: - matchLabels: - app: example-nginx - template: - metadata: - labels: - app: example-nginx - spec: - containers: - - name: example-nginx-instance - image: harbor.example.com/library/example-nginx-image:1.0.0 - imagePullPolicy: Always - ports: - - containerPort: 80 - imagePullSecrets: - - name: harbor-registry-secret - ``` - -1. Apply the configuration file to your cluster: - - ```command {title="Your workstation"} - kubectl apply -f example-nginx-deployment.yml - ``` - -1. Verify that the deployment has completed successfully by listing the pods. You should see three, each with a `Running` status. - - ```command {title="Your workstation"} - kubectl get pods - ``` - - ```output - NAME READY STATUS RESTARTS AGE - example-nginx-app-646f4d5b6-8j8xc 1/1 Running 0 1m - example-nginx-app-646f4d5b6-gnlbk 1/1 Running 0 1m - example-nginx-app-646f4d5b6-pdr24 1/1 Running 0 1m - ``` - -1. Check to see that the deployed application is performing as expected. The custom Docker image serves a static web page, so you can visit the web page to see that it is working. - - You can use kubectl to forward port `80` from within the cluster. Forward this traffic to port `8001` on your local workstation: - - ```command {title="Your workstation"} - kubectl port-forward service/example-nginx-service 8001:80 - ``` - - Navigate to `localhost:8001` in a web browser to see the deployed application. - -## Conclusion - -You now have an operational Harbor registry. You have also authenticated your Docker CLI and a Kubernetes cluster with the registry. Between these tools, you have all you need to start managing a full registry and including it into your infrastructure. - -To learn more about managing your Harbor registry and about the configuration features, be sure to refer to the Harbor documentation linked below. The Harbor dashboard gives you extensive control of access policies and roles, vulnerability scanning, and other features to secure your registry. diff --git a/docs/guides/kubernetes/using-octant-with-kubernetes-a-tutorial/index.md b/docs/guides/kubernetes/using-octant-with-kubernetes-a-tutorial/index.md deleted file mode 100644 index 5aafe7368cb..00000000000 --- a/docs/guides/kubernetes/using-octant-with-kubernetes-a-tutorial/index.md +++ /dev/null @@ -1,325 +0,0 @@ ---- -slug: using-octant-with-kubernetes-a-tutorial -title: "A Overview of Using Octant with Kubernetes" -title_meta: "How to Use Octant with Kubernetes (A Tutorial)" -description: "Octant is a visual web-based dashboard for Kubernetes clusters. This guide explores Octant's interface and how it makes troubleshooting Kubernetes easier." -authors: ["Linode"] -contributors: ["Linode"] -published: 2019-11-06 -keywords: ['octant','kubernetes','cluster','graph','dashboard','troubleshoot'] -tags: ["monitoring","kubernetes","web application"] -license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)' -image: using-octant-with-kube.jpg -external_resources: -- '[Octant](https://octant.dev/)' -- '[Octant on GitHub](https://github.com/vmware-tanzu/octant)' -- '[Octant on Twitter](https://twitter.com/projectoctant)' -aliases: [] ---- - -## What is Octant? - -Octant is a web application that talks to your Kubernetes clusters and provides an easy-to-read dashboard for the objects in your clusters. A marquee feature of Octant is its ability to show your objects and their relations in a graph format: - - - -Octant aims to be developer-centric. It is designed to help application developers (who may not be familiar with Kubernetes) better understand how their applications are deployed and troubleshoot issues when they arise. - -### In This Guide - -This guide will explore a few ways to use Octant with some example software deployments: - -- You'll see how to [navigate Octant's main interfaces](#navigating-the-interface) after a Helm chart has been installed on a cluster. - -- A [troubleshooting thought experiment](#troubleshooting-with-octant) will show how Octant can make discovering issues in your cluster easier. - -{{< note >}} -This guide assumes familiarity with the Kubernetes concepts outlined in Linode's [Beginner's Guide to Kubernetes](/cloud/guides/beginners-guide-to-kubernetes). If you have never set up a Kubernetes cluster before, it's also recommended that you do so to get the most out of this guide. The [How to Deploy Kubernetes on Linode with the k8s-alpha CLI](/cloud/guides/how-to-deploy-kubernetes-on-linode-with-k8s-alpha-cli) guide describes a one-line command for generating a cluster. -{{< /note >}} - -## Before you Begin - -The examples in this guide have been tested on a cluster running with Linode with Linode's [CCM](/cloud/guides/kubernetes-reference#linode-cloud-controller-manager) and [CSI](/cloud/guides/kubernetes-reference#container-storage-interface) plugins installed. If you would like to install these examples as well, a cluster made with [k8s-alpha CLI](/cloud/guides/how-to-deploy-kubernetes-on-linode-with-k8s-alpha-cli) will meet these criteria. - -{{< note type="alert" >}} -These examples will create billable services. To stop billing for these services after reading the guide, be sure to read the tear-down instructions at the end of each section. If you created a new cluster for this guide, you can remove the cluster's Nodes from the [Linode Cloud Manager](https://cloud.linode.com). - -If you remove the resources afterward, you will only be billed for the hour(s) that the resources were present on your account. Consult the [Billing and Payments](https://techdocs.akamai.com/cloud-computing/docs/understanding-how-billing-works) guide for detailed information about how hourly billing works. [Linode's pricing page](https://www.linode.com/pricing/) lists the rate for each Linode service. -{{< /note >}} - -## Installing Octant - -Octant does not run in your cluster. Instead, it connects to your cluster remotely and observes activity within the cluster. It also does not require special privileges to run--Octant will use the same context information that you use for kubectl. This also means that users with restricted access to a cluster can run Octant; Octant will just display the objects that are visible to that user. - -Octant can be run as a local server process on your workstation. To install and run it: - -1. Install from a package available on your operating system: - - - **Linux**: download a `.deb` or `.rpm` from the [releases page](https://github.com/vmware-tanzu/octant/releases) on GitHub, then install it with `dpkg -i` or `rpm -i`. For example: - - ```command - wget https://github.com/vmware-tanzu/octant/releases/download/v0.9.1/octant_0.9.1_Linux-64bit.deb - dpkg -i octant_0.9.1_Linux-64bit.deb - `` - - - **macOS**, with Homebrew: - - ```command - brew install octant - ``` - - - **Windows**, with Chocolatey: - - ```command - choco install octant - ``` - - {{< note >}} - Alternative installation instructions are available in the project's [README](https://github.com/vmware-tanzu/octant#installation) on GitHub. - {{< /note >}} - -1. Then, start the server. In your terminal, run: - - ```command - octant - ``` - -1. If it starts successfully, you should see a message similar to: - - ```output - ... - - Dashboard is available at http://127.0.0.1:7777 - ``` - - {{< note >}} - If it does not start successfully, check that you can connect to your cluster with kubectl. For example, try running: - - ```command - kubectl get pods - ``` - {{< /note >}} - -1. The dashboard may load automatically in your browser, or you can load the dashboard address (e.g. `http://127.0.0.1:7777`) in your browser if it does not. You should see the Octant dashboard. - -## Navigating the Interface - -The interfaces that Octant provides are meant to be a complement, and not a replacement, for kubectl. When using Octant, you may find that you sometimes need to return to kubectl to perform certain actions. Still, the Octant dashboard will serve as a helpful overview when inspecting your cluster. - -{{< note >}} -The cluster objects visible in the following screenshots were created by installing the [Helm chart](https://github.com/helm/charts/tree/master/stable/ghost) for the [Ghost](https://ghost.org) blogging software. The [How to Install Apps on Kubernetes with Helm 2](/cloud/guides/how-to-install-apps-on-kubernetes-with-helm-2) guide outlines how to install this software. Please note that this guide uses Helm 2 and not Helm 3 to install the software. -{{< /note >}} - -- When first viewing the dashboard, a list of all of your cluster objects will be shown: - -  - - The left navigation will display a hierarchy of the objects that can be viewed, and the right column will display your objects. In the right corner of the top navigation, you can quickly switch between your workstation's cluster contexts. The top navigation also allows you to change between cluster namespaces, and to filter your objects by label. - -- Consider the Services item in the left navigation. When clicked on, only your Services will appear in a table to the right: - -  - -- Important attributes of your Services will be listed in the columns of this table. In particular, the labels are buttons which can be clicked on: - -  - - If you click on the **release:my-blog** button, all Services without this label will be hidden: - -  - - This view shows that the Ghost Helm chart set up two Services: one for the Ghost front-end, and one for its database. - - {{< note >}} - Multiple labels can be selected at the same time. - {{< /note >}} - -- This filter will persist across all other views. For example, if you navigate to the Pods view, only Pods with the `release:my-blog` label will be shown. To clear your filters, click the **clear filters** link under the filter dropdown in the top navigation: - -  - -### Inspecting an Object - -Clicking on an object will show more detail for that object, including the visual graph view for that object's relationships. - -- For example, the detail view for the Ghost front-end service shows a summary with **Configuration**, **Status**, **Metadata**, **Endpoints**, and **Events** panels: - -  - - - The **Configuration** panel makes it easy to see which selector the Service uses to identify your Pods. This can also be directly edited (via the **Edit** link in the panel). Octant's development roadmap includes adding more direct-editing features like this. - - - The **Status** panel shows the external IP address for the Service, because it was implemented with type `LoadBalancer`. If you view this IP in your browser, you will see the Ghost blog. - - - The **Endpoints** tab shows the Service's Pods. - - - The **Events** tab shows the history of events for the Service. This information can be useful when troubleshooting. - - {{< note >}} - Other panels will appear for different object types. For example, Pods will show container environment variables, Volume mounts, node resources requests and limits, and taints, among other information. - {{< /note >}} - -- The **Resource Viewer** tab will reveal the object relationship graph for this Service: - -  - - This view will display color-coded cells for each object, indicating the object's status. The presence or absence of objects in this graph can be helpful when troubleshooting. For example, if a Service's graph does not show connections to a Pod, then the Service may not be configured to use the right Pod selector. - -- The third **YAML** tab shows the YAML representation for the object. - - {{< note >}} - The detail view for Pods will also show a fourth **Logs** tab,which will follow and display the logs for a Pod in real-time: - -  - {{< /note >}} - -### Navigation Example Tear-Down - -To delete the objects created by the Helm chart used in this section, run: - -```command -helm delete