# Classes Attributes vs Object Attributes

## Class Attributes

```python
class Vehicle:
	
	color = 'red' # This should not be changed
	engine = 'v6' # Should be static and should not be changed
 	
	def __init__(self, body_type, make):
		self.vehicle_body = body_type
		self.vehicle_make = make
		
```

{% hint style="danger" %}
**!!! BAD PRACTICE TO CHANGE THE CLASS ATTRIBUTES !!!**&#x20;
{% endhint %}

```python
# To change the color from the Class above, which you should not do:

Vehicle.color = 'green'
```

* This becomes a design problem as there are thousands of lines of code in a program.

**!!! THIS IS ALSO A BAD PRACTICE !!! :**

### Instance Variable

```python
car1 = Vehicle('suv', 'toyota')

# By changing the color for the car1 instance
# This changes the color just for the car1 instance
car1.color = 'purple'

# The class does not have a engine variable but by assigining it, you are creating an instance variable called v6 for car1. 
# The rest of the cars do not have an engine attribute
car1.engine = 'v6'
```

* This also becomes a design issue as other developers can assign car instances willy nilly making this an issue
* Makes interpreting the code hard

### Overview Recap:

```python
class Vehicle:
	# The varialbe should not be changed outside of the class specification
	# This is a class attribute
	vehicle_counter = 0
 	
	# This method will always run
	def __init__(self, body_type, make):
		self.vehicle_body = body_type
		self.vehicle_make = make
	
	# Returning a class attribute should be associated with the class
	# Should not be associated with the instance (self)
	def get_vehicle_count(self):
		return Vehicle.vehicle_counter
		
		# This increments the Class value and is not instance related
		Vehicle.vehicle_counter += 1
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arkannis.net/programming/courses/python-pcap-31-03-course/modules-packages-and-oop/classes-attributes-vs-object-attributes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
