Skip to main content
deleted 2 characters in body
Source Link
timgeb
  • 79.2k
  • 20
  • 129
  • 150

Suppose I create a class:

defclass SomeClass():    def __init__(self, some_attribute): self._attribute = some_attribute @property def attribute(self): return self._attribute 

Then, I add a method new_method to my object that will use the "attribute". Therefore, should I use self._attribute or self.attribute?:

def new_method(self): DoSomething(self.attribute) # or DoSomething(self._attribute) 

Does it make any impact or difference?

Suppose I create a class:

def SomeClass():   def __init__(self, some_attribute): self._attribute = some_attribute @property def attribute(self): return self._attribute 

Then, I add a method new_method to my object that will use the "attribute". Therefore, should I use self._attribute or self.attribute?:

def new_method(self): DoSomething(self.attribute) # or DoSomething(self._attribute) 

Does it make any impact or difference?

Suppose I create a class:

class SomeClass:  def __init__(self, some_attribute): self._attribute = some_attribute @property def attribute(self): return self._attribute 

Then, I add a method new_method to my object that will use the "attribute". Therefore, should I use self._attribute or self.attribute?:

def new_method(self): DoSomething(self.attribute) # or DoSomething(self._attribute) 

Does it make any impact or difference?

Grammar/capitalization/punctuation improvements for clarity
Source Link
Steven
  • 15.4k
  • 7
  • 49
  • 80

should i Should I use property or private attribute?

Suppose I create a class  :

def SomeClass():   def __init__(self, some_attribute): self._attribute = some_attribute @property def attribute(self): return self._attribute 

Then, I add a method new_method to my object that will use the "attribute". Therefore, should I use self._attribute or self.attribute?:

def new_method(self): DoSomething(self.attribute) # or DoSomething(self._attribute) 

Does it havemake any impact or difference  ?

should i use property or private attribute

I create a class  :

def SomeClass(): __init__(self, some_attribute): self._attribute = some_attribute @property def attribute(self): return self._attribute 

Then, I add a method new_method to my object that will use the "attribute". Therefore, should I use self._attribute or self.attribute:

def new_method(self): DoSomething(self.attribute) # or DoSomething(self._attribute) 

Does it have any impact or difference  ?

Should I use property or private attribute?

Suppose I create a class:

def SomeClass():   def __init__(self, some_attribute): self._attribute = some_attribute @property def attribute(self): return self._attribute 

Then, I add a method new_method to my object that will use the "attribute". Therefore, should I use self._attribute or self.attribute?:

def new_method(self): DoSomething(self.attribute) # or DoSomething(self._attribute) 

Does it make any impact or difference?

Source Link
Steven
  • 15.4k
  • 7
  • 49
  • 80

should i use property or private attribute

I create a class :

def SomeClass(): __init__(self, some_attribute): self._attribute = some_attribute @property def attribute(self): return self._attribute 

Then, I add a method new_method to my object that will use the "attribute". Therefore, should I use self._attribute or self.attribute:

def new_method(self): DoSomething(self.attribute) # or DoSomething(self._attribute) 

Does it have any impact or difference ?