484 self.__file_id = file_id
485 self.set_url(url)
486
487 def url(self):488 if self.__expiration == -1:
489 return self.url
490 if self.__expiration <= int(time.time() * 1000) + 5 * 60 * 1000:
When a method has the same name as an attribute (defined in the ancestor class or the same class), the attribute takes precedence and hides the method. Python will throw an error when the method is called.
class Example:
def __init__(self, pie="Apple"):
self.pie = pie
def pie(self):
...
Here, if the class is instantiated with a value for pie
, the method pie
would be hidden.
So, a function call like this: Example("apple").pie()
will raise a run time error — TypeError: 'str' object is not callable
.
It is recommended to have different names for attributes and methods.
class Example:
def __init__(self, pie="Apple"):
self.pie = pie
def make_pie(self): # No longer shadowed by self.pie
...