Question: ```
class MyClass(object):
    next_number = 0

    def __init__(self):
        self.number = self.next_number
        MyClass.next_number += 1

class MyClassA(MyClass):
    pass

```

Above it would appear I am forced hardcode the class name when updating the class variable on line 6 since writing:

```
self.__class__.next_number += 1

```

results in a new class variable in any derived class. Is there any alternative to hardcoding the class name?

Also on line 5 should I instead write:

```
self.number = self.__class__.next_number

```

to make it obvious next\_number is a class variable.

Answer: 
You are correct that `self.__class__.next_number` would create a variable for each class that instantiate an object that calls this `__init__`. 

You have 2 choices: hard code the class name as you did, or do not call `super().__init__` from the derived class.
I would go with the former.

In my opinion, you are unnecessarily worried about hard coding the class name here. After all, the class name is "hard coded" in this module already anyway when you do `class MyClass(object):`.

Regarding your second comment, it is a good consideration to have. I would go with: `self.__class__.next_number += 1`. Not only is this more explicit to the reader, but it also guarantees that you keep the appropriate behaviour, should you mistakenly define self.next\_number later on.
```
class MyClass(object):
    next_number = 0

    def __init__(self):
        self.number = self.__class__.next_number
        self.__class__.next_number += 1

class MyClassA(MyClass):
    pass

a = MyClassA()
print a.next_number
b = MyClassA()
print a.next_number, b.next_number
print a.number, b.number

```

output is

```
  1
  2, 2
  0, 1

```

Is this what you need?