I\'ve been using the following python code to format an integer part ID as a formatted part number string:
pn = \'PN-{:0>9}\'.format(id)
You might find simulating scanf interresting.