pupy.foreign

Module Contents

files_gen(dirpath=getcwd(), abs=True)

Yields paths beneath dirpath param; dirpath defaults to os.getcwd()

Parameters:
  • dirpath – Directory path to walking down/through.
  • abs – Yield the absolute path
Returns:

dirs_gen(dirpath=getcwd(), abs=True)

Yields paths beneath dirpath param; dirpath defaults to os.getcwd()

Parameters:
  • dirpath – Directory path to walking down/through.
  • abs – Yield the absolute path
Returns:

chunks(list, chunk_size)

Yields chunks of something slicable with length <= chunk_size

Parameters:
  • list (list or tuple) – list to be broken up
  • chunk_size (int) – size of the chunks
is_permutation(a, b)

Checks if two integers or lists are permutations lists are permutations

Parameters:
  • a (int or list) – possible perumtation of b
  • b (int or list) – possible perumtation of a
Returns:

True if a and b are permutations of one another; False otherwise

Return type:

bool

rotate(rlist, rn=1, left_rotate=True)

Rotate a list (rlist) by rn indices to the left or right

Parameters:
  • rlist (list or tuple) – list/toople or slicable to be rotated
  • rn (int) – steps bywhich to rotate (Default value = 1)
  • left_rotate (bool) – True (default) left rotates; False right rotates.
Returns:

rotated list

Return type:

list

rotations_gen(rlist)

Yields all rotations of a list

Parameters:rlist
digits_list(number)

Returns a list of the digits in num

Parameters:number (int) – number w/ digits to be listsed
Returns:-> digits in a list
Return type:list
int_from_digits(digits)

Converts an iterable of digits digits to a number

The iteratble can be ints or strings/chars

Return type:int
iter_product(l)

Product of all the elements in a list or tuple

Parameters:l – list with integer elements
Returns:product of all the elements in a list
Return type:int