Non-idempotent Python
def method():
    if 'a' not in vars():a=0
    a+=1
    if 'a' not in vars():a=0
    a+=1
    print(a)


Initializes the variable a to 0 only if it's not already initialized in the variables table. Then, increments it.

More briefly (thanks to histocrat for len):

def method():
    a=len(vars())+1
    a=len(vars())+1
    print(a)


If the two copies of X could be on the same line, we could do

a=0;a+=1;a


which doubles to 

a=0;a+=1;aa=0;a+=1;a


with the "sacrificial lamb" aa eating up the second variable assignment.