Hello,
To avoid the UnboundLocalError, out of curiosity, can't a global variable be declared somehow within an objet instead of at the top level and having to use "global"?
Thank you.
Edit: Is there a way to avoid Cloudfare's annoying "Performing security verification - This website uses a security service to protect against malicious bots. This page is displayed while the website verifies you are not a bot." ?
--
Edit: Turns out this does work:
To avoid the UnboundLocalError, out of curiosity, can't a global variable be declared somehow within an objet instead of at the top level and having to use "global"?
Thank you.
URL = "https://www.acme.com" class MyFrame(wx.Frame): #No change #URL = "https://www.acme.com" def Dload(self): #UnboundLocalError: cannot access local variable 'URL' where it is not associated with a value #response = requests.get(URL) #No change #response = requests.get(self.URL) #fixed. Is there a better way? global URL response = requests.get(URL) ...--
Edit: Is there a way to avoid Cloudfare's annoying "Performing security verification - This website uses a security service to protect against malicious bots. This page is displayed while the website verifies you are not a bot." ?
--
Edit: Turns out this does work:
import wx
class ListBoxFrame(wx.Frame):
URL = "https://www.acme.com"
def Dload(self):
print("URL/2:",self.URL)
def __init__(self, *args, **kwargs):
super().__init__(None, wx.ID_ANY,size=(1000,400), title='blah')
print("URL/1:",self.URL)
self.Dload()
panel = wx.Panel(self, -1)
panel.Layout()
app = wx.App()
ListBoxFrame().Show()
app.MainLoop()
