randword Package

randword Package

The Python module for generating random English words.

rand_word Module

randword.rand_word.word(count: Optional[int] = None, include_pos: Optional[List[str]] = None, exclude_pos: Optional[List[str]] = None, word_len: Optional[int] = None, min_word_len: int = 1, max_word_len: Optional[int] = None, starts_with: Optional[str] = None, ends_with: Optional[str] = None, pattern: Optional[str] = None) → Union[str, List[str]][source]

Returns a random English word or a list of words

Abbreviation “pos” means “part of speech”

Parameters:
  • count (int, optional) – The number of words to be generated. Defaults to None.
  • include_pos (list of str, optional) – List of parts of speech that will be included in the generation. Defaults to None
  • exclude_pos (list of str, optional) – List of parts of speech that will be excluded in the generation. Defaults to None
  • word_len (int, optional) – Specifies the length of a word. Ignores the min_word_len and max_word_len parameters. Defaults to None
  • min_word_len (int, optional) – The minimum word length. Defaults to 1
  • max_word_len (int, optional) – The maximum word length. Defaults to None
  • starts_with (str, optional) – The pattern with which the word begins. Defaults to None
  • ends_with (str, optional) – The pattern with which the word ends. Defaults to None
  • pattern (str, optional) – The pattern that should be contained in the word. Defaults to None
Returns:

A random English word if count is None or a list of them if count is not None

Return type:

Union[str, List[str]]

Raises:

IndexError – If the word was not found or if the desired number of words was not found

rand_name Module

randword.rand_name.fullname(count: Optional[int] = None, gender: Optional[str] = None) → Union[str, List[str]][source]

Returns a random fullname or a list of them

Parameters:
  • count (int, optional) – The number of fullnames to be generated. Defaults to None
  • gender (str) – Specifies the fullname of which gender will be generated. Defaults to None
Returns:

A random fullname if count is None or a list of random fullnames if count is not None

Return type:

Union[str, List[str]]

randword.rand_name.name(count: Optional[int] = None, gender: Optional[str] = None) → Union[str, List[str]][source]

Returns a random first name or a list of them

Parameters:
  • count (int, optional) – The number of names to be generated. Defaults to None
  • gender (str, optional) – Specifies the name of which gender will be generated. Defaults to None
Returns:

A random first name if count is None or a list of random first names if count is not None

Return type:

Union[str, List[str]]

randword.rand_name.surname(count: Optional[int] = None) → Union[str, List[str]][source]

Returns a random surname or a list of them

Parameters:count (int, optional) – The number of surnames to be generated. Defaults to None
Returns:A random surname if count is None or a list of surnames if count is not None
Return type:Union[str, List[str]]

rand_place Module

randword.rand_place.city(count: Optional[int] = None) → Union[str, List[str]][source]

Returns a random city or a list of them

Parameters:count (int, optional) – The number of cities to be generated. Defaults to None
Returns:A random city if count is None or a list of cities if count is not None
Return type:Union[str, List[str]]
randword.rand_place.country(count: Optional[int] = None) → Union[str, List[str]][source]

Returns a random country or a list of a random countries

Parameters:count (int, optional) – The number of countries to be generated. Defaults to None
Returns:A random country if count is None or a list of countries if count is not None
Return type:Union[str, List[str]]

rand_letter Module

randword.rand_letter.digit(count: Optional[int] = None) → Union[str, List[str]][source]

Returns a random digit

Parameters:count (int, optional) – The number of digits to be generated. Defaults to None
Returns:A single digit if count is None or a list of digits if count is not None
Return type:Union[str, List[str]]
randword.rand_letter.letter(count: Optional[int] = None) → Union[str, List[str]][source]

Returns a random ASCII letter or a list of them

Parameters:count (int, optional) – The number of letters to be generated. Defaults to None
Returns:An ASCII letter if count is None or a list of letters if count is not None
Return type:Union[str, List[str]]
randword.rand_letter.sequence(count: Optional[int] = None, length: int = 8) → Union[str, List[str]][source]

Returns a random sequence consisting of ASCII symbols and digits or a list of a random sequences

Parameters:
  • count (int, optional) – The number of sequances to be generated. Defaults to None
  • length (int, optional) – The length of the sequence. Defaults to 8
Returns:

The sequence if count is None or a list of sequences if count is not None

Return type:

Union[str, List[str]]

rand_other Module

randword.rand_other.flip_coin() → int[source]
randword.rand_other.getrandbits(k) → x. Generates an int with k random bits.
randword.rand_other.magic_8ball() → None[source]
randword.rand_other.random() → x in the interval [0, 1).