Random String Generation

You can use System.Guid to easily generate a random string in IronPython.

from System import Guid myguid = Guid.NewGuid print myguid.ToString('N') raw_input

ToString can take these strings as a parameter:


 * 'N'

32 digits:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


 * 'D'

32 digits separated by hyphens:

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx


 * 'B'

32 digits separated by hyphens, enclosed in brackets:

{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}


 * 'P'

32 digits separated by hyphens, enclosed in parentheses:

(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

Back to Contents.