---
title: do not assign to itself
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > do not assign to itself
---

# do not assign to itself

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site). ().
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**ID:** `python-best-practices/self-assignment`

**Language:** Python

**Severity:** Notice

**Category:** Best Practices

## Description{% #description %}

Do not assign a value to itself. Instead, assign the value to a different variable to make the data flow clear to read and understand.

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```python
def foo():
	bar = bar  # avoid self assignment
```

## Compliant Code Examples{% #compliant-code-examples %}

```python
def foo():
	bar = baz
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 