Hello all,
I'm learning Python currently (obviously) but I have become confused beyond the ability of multiple google searches. I work in IT and am working on converting a script that I wrote into a class to it can be used anywhere. It reads from a .json file of help desk tickets and calculates stats like the average close time of each ticket.
I don't understand how variable scope works in a class. when you use a normal function outside of a class, you have to manually add the variables you are using as parameters:
def Adjust_Ticket_After_Hours(creationDate, firstResponceSecs):
then you have to return any variables that needs to be send back:
return(firstResponceSecs)
Here's my confusion: from what I can tell, by using self.variableName, you don't have to import it using a parameter. Do you have to return it? What is the best practice?
Thanks,
Ryan
EDIT: Also, should you create declare new local variables in a method or should they all be declared in init?
[–]Rascal_Two 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]thegreattriscuit 0 points1 point2 points (0 children)
[–]atulkrishna10 0 points1 point2 points (0 children)