Python Error Saying "AttributeError: Can't Set Attribute". How Is It Possible?

778    Asked by Amitraj in Python , Asked on Nov 21, 2022

 I run R on Windows and have a CSV file on the Desktop. I load it as follows,

x<-read.csv("C:UserssurfcatDesktop2006_dissimilarity.csv",header=TRUE)

but the R gives the following error message

Error: 'U' used without hex digits in character string starting "C:U"

So what's the correct way to load this file? I am using Vista

Answered by Amit jaisawal

The reason you are getting this error is because you are naming the setter method incorrectly. You have named the setter method as set_x which is incorrect, this is why you are getting the Attribute Error saying that python can't set attributes.


To fix this error, instead of naming it as set_x you need to give it the same name as the property you creating a setter for, in you case you can do it like this:

@x.setter
def x(self, value):
    'setting'
    self._x = value


Your Answer

Interviews

Parent Categories