Posted under » PHP » Python on 26 May 2023
To share var across functions, you need to declare the var as global. Example in PHP
function replcae() // replaces stuff { global $kontent; $kontent = str_replace(" "," ",$kontent); } function k0ntent() { global $kontent, $folio; foli0(); $kontent = implode('', file($folio.".html")); replcae($kontent); }
In Python or rather Django, it may look like this, where slatus is global
def showstatus(request): global slatus current_user_id = request.user.id checkobj = Progress.objects.filter(user_id=current_user_id) if checkobj.exists(): atus=checkobj.order_by('id').last() status = atus.status if "b-" in status : slatus = 'Diagnostic' return slatus def showqtogo(request): showstatus(request) if slatus=='Diagnostic': slage = 1 checkobj = Users.objects.filter(stage=slage) if checkobj.exists(): q2go = str(checkobj.count()) return q2go