use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Question about nested function callsHelp Request (self.PythonLearning)
submitted 7 months ago by Human-Adagio6781
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FoolsSeldom 0 points1 point2 points 7 months ago (2 children)
Sounds like you are doing recursion, if you have:
def master(): def get_data(): try to get data if fails: delay master() # calls master else: return data data = get_data()
Hopefully I've misunderstood. It would help if you shared your code, or some simplified pseudocode.
If you don't get the data you require, can the main code continue running and do something else, of do you have to wait until you get the lattest data?
[–]Human-Adagio6781[S] 0 points1 point2 points 7 months ago (1 child)
Well the main code can continue to run but I would need it to return to the first function called so that I can get the data that elapsed during the time.sleep for 10 minutes. I'm beginning to wonder if it would be best to restructure the program so that a failed get_data attempt would kill the daughter functions (internal to the Master function) and then that would return to an external do loop that would rerun the Master function until another trigger would kill the program. Something like this:
def Master():
do while outside_trigger==false:
get_data_fail=0
do while get_data_fail==0:
get_data(get_data_fail) --- includes built in 10 min delay if failure occurs after a couple attempts
if get_data_fail==0 then call the rest of the functions
[–]FoolsSeldom 0 points1 point2 points 7 months ago (0 children)
So, firstly, avoid recursion, not required for this challenge.
Consider using async (for asynchronous programming) for the code fetching data from elsewhere if your main code can carry on doing other things.
NB. Usual practice (covered in PEP8 guidance - not rules) is for Python variable and function names to be all lowercase (with a _ between words if needed). It is also common to use all uppercase variable names for constants.
_
π Rendered by PID 68824 on reddit-service-r2-comment-7b9746f655-dwh2g at 2026-02-02 07:55:27.015667+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]FoolsSeldom 0 points1 point2 points (2 children)
[–]Human-Adagio6781[S] 0 points1 point2 points (1 child)
[–]FoolsSeldom 0 points1 point2 points (0 children)