Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function .get_random_word returns None too often (% depends of parameters) #79

Open
byhlel opened this issue Apr 27, 2022 · 2 comments
Open

Comments

@byhlel
Copy link

byhlel commented Apr 27, 2022

The get_random_word function returns None to often
When called with various parameters, it returns None rather than a word...

To Reproduce
Here is the code to test on your own:

from random_word import RandomWords
r=RandomWords()
for i in range (100):
	word=r.get_random_word(hasDictionaryDef="true")
	print(word)

Expected behavior
I would have expected for a word to be returned for each case, it becomes enev more obvious when you add a maxLength (in my case but probably with other parameters too)

Screenshots
This is a screenshot with following parameters:

hasDictionaryDef="true"
maxLength=10

words_lenght10_dicdef

Environment (please complete the following information):

  • OS: Windows
  • Python [3.10]

Additional Informations
Do not hesitate to comment for any additionnal informations towards my issue!

Greetings
Thank you for taking time to read and I hope we will be able to fix this issue!
Bilal.

@KonstantinKlepikov
Copy link

@byhlel

def get_random_word() -> str:

    def roll():
        result = rw.get_random_word()
        if not result:
            result = roll()
        return result

    return roll()

@byhlel
Copy link
Author

byhlel commented Sep 10, 2022

@byhlel

def get_random_word() -> str:

    def roll():
        result = rw.get_random_word()
        if not result:
            result = roll()
        return result

    return roll()

This seems indeed to be a good workaround, but it was to mainly point out the issue to the package owners.
Thank you very much though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants