How can I generate a alphanumeric series in Python -


i want generate alphanumeric series printing invoice number.

example: mt00001, mt00002, mt00003

it should not random.

please me.

looks pretty straight forward

>>> class letter_generator: ...  def __init__(self, prefix, places): ...   self.prefix = prefix ...   self.places = places ...  current = 0 ...  def get_unique_id(self): ...   self.current+=1 ...   return "%s%s" % (self.prefix, str(self.current).zfill(self.places)) ... >>> >>> l = letter_generator('tm',5) >>> l.get_unique_id() 'tm00001' >>> l.get_unique_id() 'tm00002' >>> l.get_unique_id() 'tm00003' >>> l.get_unique_id() 'tm00004' >>> 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -