🌐
Stack Overflow
stackoverflow.blog › 2021 › 07 › 14 › getting-started-with-python
Getting started with... Python - Stack Overflow
July 14, 2021 - In case you were wondering, The Zen Of Python is available in catchy musical form here. The official tutorial is a quick primer on all the basics, perfect for getting up and running quickly.
🌐
LinkedIn
linkedin.com › learning › python-for-students-2019 › stack-overflow
Stack Overflow - Python Video Tutorial | LinkedIn Learning, formerly Lynda.com
November 1, 2019 - Stack Overflow is a great website for asking questions and getting help using Python. In this video, learn how to use Stack Overflow to get help using Python.
Discussions

Newest 'python' Questions - Stack Overflow
Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal. ... Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I am trying to run Thonny 5.0.0 on an Apple Silicon Mac running an environment with Python ... More on stackoverflow.com
🌐 stackoverflow.com
Python Stack Overflow
Use a loop instead of recursion. More on reddit.com
🌐 r/learnpython
10
1
August 13, 2021
Python for beginners - Stack Overflow
Python programming: I need to write a program that takes two inputs of military time. For example,(0900,1700) and output the time differences of the two input in numbers in hours, minutes ex: pr... More on stackoverflow.com
🌐 stackoverflow.com
What resources did YOU use to learn Python?
The most important thing I used to learn Python (and any other language for that matter) was a useful project. If you've got that then you can't go wrong. More on reddit.com
🌐 r/Python
41
7
November 5, 2013
🌐
Stack Overflow
stackoverflow.blog › python
python - Stack Overflow
April 30, 2026 - Get The Stack Overflow Podcast at your favorite listening service. Apple Podcasts Overcast Pocket Casts Spotify RSS feed ... Agents are everywhere, so isn't it fitting that the Worst Coder in the World goes agentic? A coding newbie explores the challenges and rewards of building an agent for work—and trying to learn a few things about coding along the way. ... Travis Oliphant, creator of NumPy and SciPy, joins Ryan to explore the development of Python ...
🌐
Stack Overflow
stackoverflow.com › questions › tagged › python
Newest 'python' Questions - Stack Overflow
I am executing the following script: #!/usr/bin/env python3 import torch as T from peft import LoraConfig, get_peft_model, TaskType from transformers import AutoModelForCausalLM, AutoTokenizer, ... ... I want to print a quote and then replace it with another when I am done with it. My code works when both the quote text and source fit on a line each, but if the text would overflow to the next line (...
🌐
Codementor
codementor.io › python › tutorial › stack-overflow-python-expert-answers-questions
Python Q&A with #1 Stack Overflow Python Expert | Codementor
Codementor Python expert and Stack Overflow legend Martijn Pieters joined us for a session in office hours to share his insights about Python programming.
🌐
Reddit
reddit.com › r/learnpython › python stack overflow
r/learnpython on Reddit: Python Stack Overflow
August 13, 2021 -

Hello! I am new to python. I created a script/bot, and its function is work until closed.

That bot has a main() function that one way or another calls itself after a 1 minute timer.

After some time i noticed that it crashed and closed Tested again but now in Visual Studio Code and after 18 hours it crashed again with fatal error stack overflow.

Went in and created a separate script with a main function calling itself and after 1035 loops it caused stack overflow. Now 1035*1minute is about 18 hours.

How can i create an infinite script without causing stack overflow?

Thanks!

🌐
GeeksforGeeks
geeksforgeeks.org › auto-search-stackoverflow-for-errors-in-code-using-python
Auto Search StackOverflow for Errors in Code using Python - GeeksforGeeks
December 9, 2021 - And then finally open up the tabs containing answers from StackOverflow on the browser. Note: One more thing, before we jump into the code, you should be clear with the concept of the strip and split function. ... # Import dependencies from subprocess import Popen, PIPE import requests import webbrowser # We are going to write code to read and run python # file, and store its output or error.
🌐
CodeRivers
coderivers.org › blog › python-stack-overflow
Python Stack Overflow: A Comprehensive Guide - CodeRivers
February 22, 2026 - The call stack has a limited size, which varies depending on the system and Python implementation. Infinite Recursion: This is one of the most common causes. When a recursive function does not have a proper base case or the base case is never reached, the function keeps calling itself, and the stack keeps growing until it overflows.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 18754276 › python-for-beginners
Python for beginners - Stack Overflow
Python programming: I need to write a program that takes two inputs of military time. For example,(0900,1700) and output the time differences of the two input in numbers in hours, minutes ex: pr...
🌐
Kaggle
kaggle.com › datasets › stackoverflow › pythonquestions
Python Questions from Stack Overflow | Kaggle
October 8, 2019 - Full text of Stack Overflow Q&A about the Python programming language
Top answer
1 of 2
8

You can cause a stack overflow quite easily in python, as in any other language, by building an infinately recursive funcion. This is easier in python as it doesn't actually have to do anything at all other than be recursive.

>>> def foo():
...     return foo()
... 

>>> foo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  .......
  File "<stdin>", line 2, in foo
RuntimeError: maximum recursion depth exceeded
>>> 

As for the heap, that is managed by a garbage collector. You can allocate lots of objects and eventually run out of heap space and Python will raise a MemoryError, but it's going to take a fair amount of time. You actually did that with your 'stack overflow' example in the question. You stored a reference to a string on the stack, this string took up all the free memory available to the process. As a rule of thumb, Python stores a reference to a heap structure on the stack for any value that it can't guarantee the size of.

As for how it all works, from the fist example you can see that python has a built-in limit to the depth of the call stack that it will not exceed. The amount of memory available for heap space is defined by the OS however and will depend upon many factors.

These are should be the appropriate parts of the python docs for infomation on the errors themselves:

  • http://docs.python.org/release/3.2.3/library/exceptions.html#RuntimeError
  • http://docs.python.org/release/3.2.3/library/exceptions.html#MemoryError
2 of 2
6

please correct me if wrong:

As far as I know, when it comes to actual stack implementation, the python stack (in the default distribution) is actually based in the heap memory (memory allocated with malloc). So you cannot cause the stack overflow, but you can run out of memory. The computer slowdown you seen is because memory is being swapped to disk, very slow procedure.

generally, you have no idea how the interpreted/byte-compiled language implements its stack, but most like it is not implemented in the stack memory, so you cannot cause stack overflow. it is possible to implement Python using alloca, but why?

Cf. CPython - Internally, what is stored on the stack and heap?

Try the same experiment with compiled language, C++, Fortran, etc. which compiles to machine code.

🌐
Stack Overflow
stackoverflow.com › questions › tagged › python-3.x
Newest 'python-3.x' Questions - Stack Overflow
Explore Stack Internal ... I had the error The virtual environment was not created successfully because ensurepip is not available in a bash script running on Ubuntu VM server because phyton is installed but not venv to ... ... how do i call on a specific key from a list of dictionaries in python ?
🌐
Python
peps.python.org › pep-0651
PEP 651 – Robust Stack Overflow Handling | peps.python.org
By separating the checks for C stack overflow from checks for recursion depth, pure Python programs can run safely, using whatever level of recursion they require.
🌐
Medium
devjaime.medium.com › scraping-stack-overflow-usando-python-22ad9e2af5a4
Scraping Stack Overflow Usando Python | by Jaime Hernández | Medium
April 24, 2019 - Este tutorial se nos muestra la forma de obtener una pagina web y tomar su información para poder transformarla en un archivo json que después podrá ser encapsulada y consumida. Lo primero es descargar python de la pagina oficial
🌐
Medium
martinxpn.medium.com › what-is-stack-overflow-really-40-100-days-of-python-e5e129416d33
What is Stack Overflow Really? (40/100 Days of Python) | by Martin Mirakyan | Medium
April 10, 2023 - A stack overflow can occur in Python when a function recursively calls itself without a proper exit condition, causing the number of function calls on the call stack to grow indefinitely and eventually overflow.
🌐
Stack Overflow
stackoverflow.com › beta › discussions › 78018452 › guidance-for-learning-python
Guidance for learning python - Stack Overflow
Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal. ... Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Looking for guidance on learning python from scratch .
🌐
GitHub
github.com › drathier › stack-overflow-import
GitHub - drathier/stack-overflow-import: Import arbitrary code from Stack Overflow as Python modules. · GitHub
If that answer doesn’t have any valid python · code, it checks the next highest voted answer for code blocks. >>> from stackoverflow import quick_sort, split_into_chunks >>> print(quick_sort.sort([1, 3, 2, 5, 4])) [1, 2, 3, 4, 5] >>> print(list(split_into_chunks.chunk("very good chunk func"))) ['very ', 'good ', 'chunk', ' func'] >>> print("I wonder who made split_into_chunks", split_into_chunks.__author__) I wonder who made split_into_chunks https://stackoverflow.com/a/35107113 >>> print("but what's the license?
Starred by 3.7K users
Forked by 130 users
Languages: Python
🌐
W3Schools
w3schools.com › python › python_dsa_stacks.asp
Stacks with Python
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle.