# Variable

A variable is a named reference that represents or provides access to a value in a program.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Variables point to objects

DevFeed: [Variables point to objects](<https://devfeed.tech/articles/variables-point-to-objects-39392.md>)

Original publisher: [Read original article](<https://kt.academy/article/variables>)

Published: 2021-11-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Variable](<https://devfeed.tech/topics/variable.md>), [object](<https://devfeed.tech/topics/object.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [exception](<https://devfeed.tech/tags/exception.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [object](<https://devfeed.tech/tags/object.md>), [variable](<https://devfeed.tech/tags/variable.md>), [variables](<https://devfeed.tech/tags/variables.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

A tutorial explaining how variables reference objects, how reassignment differs from mutating an object, and how these distinctions apply to mutable and read-only Kotlin lists and delegated properties backed by maps.

### Source excerpt

A basic feature, that is commonly misunderstood.

## Why Descriptive Variable Names Improve Code Readability

DevFeed: [Why Descriptive Variable Names Improve Code Readability](<https://devfeed.tech/articles/variable-looked-at-me-and-said-say-my-name-39030.md>)

Original publisher: [Read original article](<https://vladimirj.dev/say-my-name/>)

Author: Vladimir Jovanović

Published: 2017-10-17T09:44:00Z

Content type: tutorial

Language: en

Sources: [Vladimir Jovanović](<https://devfeed.tech/sources/vladimir-jovanovic.md>)

Topics: [Variable](<https://devfeed.tech/topics/variable.md>), [Code](<https://devfeed.tech/topics/code.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Computer science](<https://devfeed.tech/topics/computer-science.md>)

Tags: [clean-code](<https://devfeed.tech/tags/clean-code.md>), [code](<https://devfeed.tech/tags/code.md>), [computer-science](<https://devfeed.tech/tags/computer-science.md>), [developer](<https://devfeed.tech/tags/developer.md>), [programming](<https://devfeed.tech/tags/programming.md>), [understand](<https://devfeed.tech/tags/understand.md>), [variable](<https://devfeed.tech/tags/variable.md>), [writing](<https://devfeed.tech/tags/writing.md>)

### AI overview

This article explains why descriptive variable names make code easier for humans to read and maintain. It contrasts short, cryptic names with clearer names and notes that naming requires judgment rather than automatically improving code.

### Source excerpt

While you are writing your code, the most important thing to have in mind is that you are writing your code first and foremost for humans to understand, and secondly for a machine to interpret.

## The AnyStr type variable

DevFeed: [The AnyStr type variable](<https://devfeed.tech/articles/the-anystr-type-variable-38897.md>)

Original publisher: [Read original article](<http://neopythonic.blogspot.com/2016/05/the-anystr-type-variable.html>)

Author: Guido van Rossum (noreply@blogger.com)

Published: 2016-05-17T16:53:00Z

Content type: tutorial

Language: en

Sources: [Guido van Rossum](<https://devfeed.tech/sources/guido-van-rossum.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>), [function](<https://devfeed.tech/topics/function.md>), [Variable](<https://devfeed.tech/topics/variable.md>), [networking](<https://devfeed.tech/topics/networking.md>)

Tags: [bug](<https://devfeed.tech/tags/bug.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [function](<https://devfeed.tech/tags/function.md>), [polymorphism](<https://devfeed.tech/tags/polymorphism.md>), [python](<https://devfeed.tech/tags/python.md>), [types](<https://devfeed.tech/tags/types.md>)

### AI overview

A tutorial on Python type annotations uses a parenthesize function to explain polymorphism across str and bytes, the Union type, and how static type checking exposes a bytes-versus-str bug. It introduces AnyStr as the subject of a separate discussion related to PEP 484 and the __fspath__() protocol.

### Source excerpt

The AnyStr type variable I was drafting a blog post on how to add type annotations for the new __fspath__() protocol (PEP 519) when I realized that I should write a separate post about AnyStr . So here it is. A simple function on strings Let's write a function that surrounds a string in parentheses. We'll put it in a file named demo.py : def parenthesize(s): return '(' + s + ')' It works, too: >>> from demo import parenthesize >>> print(parenthesize('hola')) (hola) Of course, if you pass it something that's not a string it will fail: >>> parenthesize(42) Traceback (most recent call last): File "demo.py", line 1, in File "demo.py", line 2, in parenthesize TypeError: Can't convert 'int' object to str implicitly Adding type annotations Using PEP 484 type annotations we can clarify our little function's signature: def parenthesize(s: str) -> str: return '(' + s + ')' Nothing to it, right? Even if you've never heard of PEP 484 before you can guess what this means. (Note that PEP 484 also says that the runtime behavior is unchanged. The calls I showed above will still have exactly the same effect, including the TypeError raised by parenthesize(42) .) Polymorphic functions Now suppose this is actually part of a networking app and we need to be able to parenthesize byte strings as well as text strings. Here's how you'd implement that: def parenthesize(s): if isinstance(s, str): return '(' + s + ')' elif isinstance(s, bytes): return b'(' + s + b')' else: raise TypeError(f"That's not a string, it's a {type(s)}") # See PEP 498 With a fancy word we call that a polymorphic function. How do you write a signature for such a function? For the answer we have to dive a little deeper into PEP 484. It defines a nifty operator named Union that lets us state that a type can be either this or that (or something else). In our case, it's either str or bytes , so we can write it like this: from typing import Union def parenthesize(s: Union[str, bytes]) -> Union[str, bytes]: if isinstance(s,

## A Reminder of Lagrange Multipliers for Optimization Problems

DevFeed: [A Reminder of Lagrange Multipliers for Optimization Problems](<https://devfeed.tech/articles/lagrangians-for-the-amnesiac-40334.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2013/11/30/lagrangians-for-the-amnesiac/>)

Published: 2013-11-30T09:00:50Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Optimization](<https://devfeed.tech/topics/optimization.md>), [function](<https://devfeed.tech/topics/function.md>), [Variable](<https://devfeed.tech/topics/variable.md>)

Tags: [convex-functions](<https://devfeed.tech/tags/convex-functions.md>), [function](<https://devfeed.tech/tags/function.md>), [gradient-descent](<https://devfeed.tech/tags/gradient-descent.md>), [lagrange](<https://devfeed.tech/tags/lagrange.md>), [lagrange-multipliers](<https://devfeed.tech/tags/lagrange-multipliers.md>), [linear-algebra](<https://devfeed.tech/tags/linear-algebra.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [problems](<https://devfeed.tech/tags/problems.md>), [variable](<https://devfeed.tech/tags/variable.md>), [vectors](<https://devfeed.tech/tags/vectors.md>)

### AI overview

A tutorial-style reminder of Lagrange multipliers for optimization problems. It reviews gradients, partial derivatives, dot products, and directional change for multivariable functions.

### Source excerpt

For a while I've been meaning to do some more advanced posts on optimization problems of all flavors. One technique that comes up over and over again is Lagrange multipliers, so this post is going to be a leisurely reminder of that technique. I often forget how to do these basic calculus-type things, so it's good practice. We will assume something about the reader's knowledge, but it's a short list: know how to operate with vectors and the dot product, know how to take a partial derivative, and know that in single-variable calculus the local maxima and minima of a differentiable function $ f(x)$ occur when the derivative $ f'(x)$ vanishes.

## False Proof: 1 = 2 (with Calculus)

DevFeed: [False Proof: 1 = 2 (with Calculus)](<https://devfeed.tech/articles/false-proof-1-2-with-calculus-40245.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2011/10/25/false-proof-1-2-with-calculus/>)

Published: 2011-10-25T14:46:12Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Math and Logic](<https://devfeed.tech/topics/math-and-logic.md>), [function](<https://devfeed.tech/topics/function.md>), [Variable](<https://devfeed.tech/topics/variable.md>)

Tags: [calculus](<https://devfeed.tech/tags/calculus.md>), [false-proof](<https://devfeed.tech/tags/false-proof.md>), [function](<https://devfeed.tech/tags/function.md>), [logic](<https://devfeed.tech/tags/logic.md>), [variable](<https://devfeed.tech/tags/variable.md>)

### AI overview

This article presents a false calculus proof that 1 equals 2 and explains that the error comes from differentiating a variable-length sum with respect to only one of its variables.

### Source excerpt

Problem: Show 1 = 2 (with calculus) "Solution": Consider the following: $ 1^2 = 1$ $ 2^2 = 2 + 2$ $ 3^2 = 3 + 3 + 3$ $ \vdots$ $ x^2 = x + x + \dots + x$ ($ x$ times) And since this is true for all values of $ x$, we may take the derivative of both sides, and the equality remains true. In other words:

## Changing the Linux Shell Prompt

DevFeed: [Changing the Linux Shell Prompt](<https://devfeed.tech/articles/changing-the-linux-shell-prompt-40663.md>)

Original publisher: [Read original article](<https://radek.io/posts/changing-the-linux-shell-prompt/>)

Published: 2011-06-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [Radek Pazdera](<https://devfeed.tech/sources/radek-pazdera.md>)

Topics: [Bash](<https://devfeed.tech/topics/bash.md>), [Shell](<https://devfeed.tech/topics/shell.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Scripting, bash](<https://devfeed.tech/topics/scripting-bash.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Variable](<https://devfeed.tech/topics/variable.md>)

Tags: [bash](<https://devfeed.tech/tags/bash.md>), [change](<https://devfeed.tech/tags/change.md>), [command](<https://devfeed.tech/tags/command.md>), [environment](<https://devfeed.tech/tags/environment.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [linux](<https://devfeed.tech/tags/linux.md>), [prompt](<https://devfeed.tech/tags/prompt.md>), [shell](<https://devfeed.tech/tags/shell.md>), [value](<https://devfeed.tech/tags/value.md>), [variable](<https://devfeed.tech/tags/variable.md>)

### AI overview

A tutorial on customizing the Bash shell prompt on Linux by changing the prompt string environment variable. It explains prompt escape sequences, colors, temporary changes, and how to make the configuration permanent.

### Source excerpt

How to modify your shell prompt on Linux