Q:

Increment counter by 1 if the type is same otherwise reset to provided start range

The intent here is increment the counter by 1 if the type name is same or else reset to 1. I also want to add custom start range. The issue here is I want to add start range once and then do incrementation by 1 and not increment by start_range+1 everytime.
class Foo(object):
    """ 
    if type is different in the argument, reset counter to 1.
    Otherwise increment counter by 1. Use start_range as a starting point.
    """

    type_name = "bar"
    counter = 1

def __init__(self, next_type_name, start_range):
    self.next_type_name = next_type_name
    self.start_range = start_range
    self.reset()

def reset(self):
    Foo.counter =self.start_range
    print self.next_type_name, Foo.type_name
    if Foo.type_name != self.next_type_name:
        print "here..."
        Foo.counter = self.start_range+1
        Foo.type_name = self.next_type_name
    else:
        Foo.counter += 1
        print Foo.counter

 print "-------------------------- bar "
 d = Foo("bar", 100)
 print d.counter
 ## result >> 101

 print "-------------------------- list "
 new_instances = []
 for i in range(0, 10):
    new_instances.append(Foo("bar", 100))
 print new_instances[i].counter
 ## result >> 102, 103, 104, 105, 106, 107, 108, 109, 110, 111

print "-------------------------- test starts here ... "
c = Foo("test", 200)
print c.counter
## result >> 201

print "-------------------------- test "
e = Foo("test", 200)
print e.counter
## result >> 202

print "-------------------------- test "
f = Foo("test", 200)
print f.counter
## result >> 203

A:

Just a little advice and then a simple demo code.
Advice:

Each type should have same start range, so start range should only init once(maybe pre-input or pre-defined) for each type before counter.
Different type map different counter, dict should be the right data structure, this can avoid alternate type reset issue.

Demo Code:
class Foo(object):
    type_counter = {}

    def __init__(self, type_name, start_range=0):
        self.type_name = type_name
        if type_name in Foo.type_counter:
            Foo.type_counter[type_name] += 1
        else:
            Foo.type_counter[type_name] = start_range + 1

    def counter(self):
        return Foo.type_counter[self.type_name]

# Following is your test data

print "-------------------------- bar "
d = Foo("bar", 100)
print d.counter()
## result >> 101

print "-------------------------- list "
new_instances = []
for i in range(0, 10):
    new_instances.append(Foo("bar"))
    print new_instances[i].counter()
## result >> 102, 103, 104, 105, 106, 107, 108, 109, 110, 111

print "-------------------------- test starts here ... "
c = Foo("test", 200)
print c.counter()
## result >> 201

print "-------------------------- test "
e = Foo("test")
print e.counter()
## result >> 202

print "-------------------------- test "
f = Foo("test")
print f.counter()
## result >> 203

Hope this help.

