Variable name generator

master
Salvo 'LtWorf' Tomaselli 2016-08-15 09:16:22 +07:00
parent 36bc145ac3
commit bd1c3a208c
1 changed files with 23 additions and 0 deletions

@ -17,3 +17,26 @@
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
#
# This module splits a query into a program.
def vargen(avoid, prefix=''):
'''
Generates temp variables.
Avoid contains variable names to skip.
'''
count = 0
while True:
r = ''
c = count
while True:
r = chr((c % 26) + 97) + r
if c < 26:
break
c //= 26
r = prefix + r
if r not in avoid:
yield r
count += 1