How to update the global variable (response) by calling that function(talk) within the same class. Seeing that you have unneeded trailing semicolons in each line I can safely assume that you're new to Python. Well, there is this class attribute (response) which I need to update in the function in the way shown above.
BTW, I have been coding in Java and yes I'm new to Python but I like the use of semicolons.
In python, i have a function that returns a list of the latest links(to folders) on a website.
I also have another function that downloads the latest files from those folders. I have a global list with the folder links that the download function accesses everytime it runs for the latest folders.
"; # class atribute def change_talk(self, response): # class methods always get `self` (the object through which they are # called) as their first argument, and it's commons to call it `self`. " XYZ_inst_2 = XYZ() ## New instance has the same response as the previous one: XYZ_inst_2.talk() #"Hi Anand! " class XYZ2(object): # you must initialise each instance of the class and give # it its own response: def __init__(self, response="Hi Pranjal! " XYZ_inst_2 = XYZ2() ## new instance has the default response: XYZ_inst_2.talk() #"Hi Pranjal! " Finally, if you really want to have a global variable (which is not really advised as for changing whatever is outside the class instance you should pass it as an argument to the method changing it): # global variable created outside the class: g_response = "Hi Pranjal!
I understand for using self, I need to pass an object but I can't create an instance of the class inside the same class right? Then I want to call that function from within the same class. There are different things that you could be trying to do, and you probably need to research a little bit more about python itself, but let's see if this helps: If you want to have a class whose instances share a common response, you can have something like this: class XYZ(object): response = "Hi Pranjal!
I want to update that global list every five days and keep it static for the next 5 days i run the code until it updates again.
Its sort of like this: So I want the update function to run every 5 days(I know how to do that) and the download function to run everyday.
I wanted to call those methods from within the same class which I later figured out is meaningless.
(version of python is 3.4.4) I'm not able to follow correctly.
What should be your expected output and what are you getting?
F1000 -- File watcher job look for filename_F1000 job starts after completion of S1000 as we set the dependency.
As per todays(Job ran on 20170322) case, S1000 sets the global variable to 20170322 at AM.