traceback (most recent call lastin (---- product( , , in product(*nums class math(object) def product(*nums)---- return functools reduce(operator mulnums def power_chain(*nums) return functools reduce(operator pownumstypeerrorunsupported operand type(sfor *'mathand 'intif your namespace is entirely bag for pure functionsthere is no reason not to call via the class rather than the instance but if you wish to mix some pure functions with some other stateful methods that rely on instance mutable stateyou should use the @staticme thod decorator generator functions special sort of function in python is one that contains yield statementwhich turns it into generator what is returned from calling such function is not regular valuebut rather an iterator that produces sequence of values as you call the next(function on it or loop over it this is discussed in more detail in the entitled "lazy evaluation while like any python objectthere are many ways to introduce statefulness into generatorin principle generator can be "purein the sense of pure function it is merely pure function that produces (potentially infinitesequence of values rather than single valuebut still based only on the arguments passed into it noticehoweverthat generator functions typically have great deal of internal stateit is at the boundaries of call signature and return value that they act like side-effect-free "black box simple exampledef get_primes()"simple lazy sieve of eratosthenescandidate found [while trueif all(candidate prime ! for prime in found)yield candidate found append(candidatecandidate + callables