Is there any inbuild func, that can be used to call Alphabets randomly..

Asked by Muzammil Basha

I want to call a func which calls a random word of alphabets and integers(at the least alphabets), else can any one tell me how define a func to call random alphabets

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1
Revision history for this message
Muzammil Basha (ksmuzzu) said :
#2

Hi RaiMan,
I tried this..

import random
import string
class sdf():
    def rand_string(self):
        output = ''
        length=5
        chr_set = string.ascii_uppercase + string.digits
        for n in range(length):
            output = output + random.choice(chr_set)
        return output
        print(output)

new = sdf()
new.rand_string()

but sikuli responding nothing.. :(

Revision history for this message
Muzammil Basha (ksmuzzu) said :
#3

any suggestions..

Revision history for this message
Best RaiMan (raimund-hocke) said :
#4

you should print before return ;-)

... better use this

import random
import string
class sdf():
    def rand_string(self):
        output = ''
        length=5
        chr_set = string.ascii_uppercase + string.digits
        for n in range(length):
            output = output + random.choice(chr_set)
        return output

new = sdf()
print new.rand_string()

Revision history for this message
Muzammil Basha (ksmuzzu) said :
#5

Thanks RaiMan, that solved my question.