stack-overflow

ANSWERED Trying to import a formula from another program

Trying to import a formula from another program Question: When I run the program my import does not work, I have tried different methods but I get the same error: "NameError: name ‘SINGLE1’ is not defined" This is the program I am running: name="What is the name of the player?:" NAME1=input(name) atbats=("Number of At-Bats for …

Total answers: 2

NoneType object is not callable error on a full dictionary, stackoverflow fatal error

NoneType object is not callable error on a full dictionary, stackoverflow fatal error Question: Im trying to make a web-scraping script. I’m bumping into an error and cant seem to figure out why. I’m using spyder IDE, so all the variables are shown in variable explorer. My code is as follows from urllib.request import Request, …

Total answers: 2

Pydantic exclude field from __eq__ to avoid recursion error

Pydantic exclude field from __eq__ to avoid recursion error Question: I have a pydantic model like this: class SomeModel(pydantic.BaseModel): name: str content: str previous_model: typing.Optional["SomeModel"] = None My code look like this, this is greatly simplified, In my real code there are many and circular dependencies occur by chance occasionally rather than being purposefully created: …

Total answers: 1

stackoverflow error in 2d fipy PDE solver in python

stackoverflow error in 2d fipy PDE solver in python Question: I am trying to solve a system of three coupled PDEs and two ODEs (coupled) in 2D. The problem tries to solve for a case of a particle moving in a medium. The medium is given by the fields- velocity components vx, vy, and density …

Total answers: 1

Why is Python recursion so expensive and what can we do about it?

Why is Python recursion so expensive and what can we do about it? Question: Suppose we want to compute some Fibonacci numbers, modulo 997. For n=500 in C++ we can run #include <iostream> #include <array> std::array<int, 2> fib(unsigned n) { if (!n) return {1, 1}; auto x = fib(n – 1); return {(x[0] + x[1]) …

Total answers: 7

Does Python optimize tail recursion?

Does Python optimize tail recursion? Question: I have the following piece of code which fails with the following error: RuntimeError: maximum recursion depth exceeded I attempted to rewrite this to allow for tail recursion optimization (TCO). I believe that this code should have been successful if a TCO had taken place. def trisum(n, csum): if …

Total answers: 8