# Aliasing in Python

In python programming, the second name given to a piece of data is known as an alias. Aliasing happens when the value of one variable is assigned to another variable because variables are just names that store references to actual value.

Consider a following example:

``````
first_variable = "PYTHON"
print("Value of first:", first_variable)
print("Reference of first:", id(first_variable))

print("--------------")

second_variable = first_variable # making an alias
print("Value of second:", second_variable)
print("Reference of second:", id(second_variable))
``````

In the example above, `first_variable` is created first and then string ‘PYTHON’ is assigned to it. Statement `first_variable = second_variable` creates an alias of `first_variable` because `first_variable = second_variable` copies reference of `first_variable` to `second_variable`.

To verify, let’s have look at the output of the above program:

```Value of first_variable: PYTHON
Reference of first_variable: 2904215383152
--------------
Value of second_variable: PYTHON
Reference of second_variable: 2904215383152
```

From the output of the above program, it is clear that first_variable and second_variable have the same reference id in memory.

So, both variables point to the same string object ‘PYTHON’.

And in Python programming, when the value of one variable is assigned to another variable, aliasing occurs in which reference is copied rather than copying the actual value.
{"ft_lang_label":"__label__en","ft_lang_prob":0.71973336,"math_prob":0.9420115,"size":1437,"snap":"2021-43-2021-49","text_gpt3_token_len":290,"char_repetition_ratio":0.25610608,"word_repetition_ratio":0.071794875,"special_character_ratio":0.23451635,"punctuation_ratio":0.12334802,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99554044,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-08T00:36:05Z\",\"WARC-Record-ID\":\"<urn:uuid:64c977a9-439e-49a7-9a04-9c2fd3bd8451>\",\"Content-Length\":\"40220\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b29a4080-43c0-462c-8d98-e98995716d73>\",\"WARC-Concurrent-To\":\"<urn:uuid:ed0b0041-27f0-4b2c-88f6-d1b90b78a8b8>\",\"WARC-IP-Address\":\"167.99.160.99\",\"WARC-Target-URI\":\"https://www.codesansar.com/python-programming/aliasing.htm\",\"WARC-Payload-Digest\":\"sha1:LNNOLHVOXNIXRTTXPA2NKCGWDHSAZKH4\",\"WARC-Block-Digest\":\"sha1:W25OPI4DMUONEXCTNIGGS5ZF6BMUDQ6Q\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964363420.81_warc_CC-MAIN-20211207232140-20211208022140-00520.warc.gz\"}"}