vaibhavsingh97 / random-word

This is a simple python package to generate random english words
https://pypi.org/project/random-word/
MIT License
123 stars 25 forks source link

get_random_word() & get_random_words() return a NoneType....!! #70

Open arixank opened 3 years ago

arixank commented 3 years ago

Describe the bug At some point in type I'm encountering a NoneType in my code, which I'm unable to try and catch nor ignore it by another method..!

To Reproduce Steps to reproduce the behavior: here is a code screen shot:

image

code:

import random

rwd = RandomWords()
choice = random.randint(0, 14)

print(choice)
word = rwd.get_random_words(limit=15)
print(word, '\n')
new_word = word[choice]
print(new_word)

Expected behavior Need to generate words or at least return a English word

Screenshots Error Screen Shot image

Environment (please complete the following information):

arixank commented 3 years ago

Even This doesn't work: image

Maxwelldoug commented 3 years ago

Same issue here under Ubuntu 20.04 LTS with python 3.9, I'll go try with 3.8

arixank commented 3 years ago

Same issue here under Ubuntu 20.04 LTS with python 3.9, I'll go try with 3.8

yes please let me know, I'm also working on several work arounds..!!

Thanks

arixank commented 3 years ago

for now this is what I'm doing for a dictionary type application..! At least string type can be done with something.

image

romanmeister commented 3 years ago

Same here, strangely enough it sometimes spits out a list type, sometimes NoneType

r = RandomWords()
random_words_list = r.get_random_words(limit=length_of_list)
Mohamed-Amine-AALI commented 3 years ago

Same here

from random_word import RandomWords
r = RandomWords()
print(r.get_random_word())

Sometimes it prints an actual word, sometimes None

kikefdezl commented 2 years ago

Still happening for me:

import random
from random_word import RandomWords

random_words = RandomWords()
words = random_words.get_random_words(limit=random.randint(1, 10), hasDictionaryDef=True)

This sometimes returns a list of random words, and sometimes returns NoneType.

Anas812001 commented 2 years ago

I managed to fix it guys image

Maxwelldoug commented 2 years ago

That's not a fix, it's a hacky workaround at best.