diff --git a/implementations/Python/simplejoy.py b/implementations/Python/simplejoy.py index f2e49b1..51abe7a 100755 --- a/implementations/Python/simplejoy.py +++ b/implementations/Python/simplejoy.py @@ -187,7 +187,7 @@ def concat(quote, expression): def get_n_items(n, stack): ''' - Return items and remainder of stack. + Return n items and remainder of stack. Raise StackUnderflowError if there are fewer than n items on the stack. ''' assert n > 0, repr(n) @@ -197,7 +197,9 @@ def get_n_items(n, stack): try: item, stack = stack except ValueError: - raise StackUnderflowError('Not enough values on stack.') from None + raise StackUnderflowError( + 'Not enough values on stack.' + ) from None temp.append(item) temp.append(stack) return tuple(temp) @@ -806,7 +808,9 @@ def rest(stack): try: _, s1 = s0 except ValueError: - raise StackUnderflowError('Cannot take rest of empty list.') from None + raise StackUnderflowError( + 'Cannot take rest of empty list.' + ) from None return s1, stack @@ -1235,6 +1239,7 @@ _map2 ≡ [infrst] cons dipd roll< swons ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ''' + class NotAListError(Exception): ''' Raised when a stack is expected but not received.