
Andres M. answered 07/21/19
Math PhD with over 15 years of tutoring experience
You cannot do usual arithmetic with infinity (even in pure mathematics.) For example, you will find that 1/math.inf evaluates to 0 in python. This is symbolic and by mathematical convention. So, in fact the symbol 1/math.inf is being stored as 0, so your "limit" is being evaluated as 1**math.inf, and defaulting by the algebra rule that 1**anything=1.
You can instead opt for using sympy, which after installation can be used to evaluate limits.
import sympy as sym
x = sym.Symbol('x')
sym.limit((1+1/x)**x, x, sym.oo)
If you need only store the value "e" for future computation, you can always store it as a variable for sufficiently large numbers, that is e=(1+1/10000)**10000.
If you want a truly robust algebra/calculus package I recommend using SageMath, which is built on top of python and completely open source.