Calling functions in the python class

how to call a class"s function in a class, for example, I wrote
class DailishiyanDownloaderMiddleware (object):

-sharp Not all methods need to be defined. If a method is not defined,
-sharp scrapy acts as if the downloader middleware does not modify the
-sharp passed objects.
def canshu(self):-sharp
    aa=["192.168.1.2","11.22.33","44,55,66"]
    return aa
b=canshu(1)
print("",b)
def order(self):-sharp
    print("order")
    for i in range(10):
        yield i
a=order(1)
@classmethod
def from_crawler(cls, crawler):
    -sharp This method is used by Scrapy to create your spiders.
    s = cls()
    crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
    return s
    ........

will output normally, but if I write it this way, I will get an error AttributeError: "int" object has no attribute" canshu"
class DailishiyanDownloaderMiddleware (object):

.
-sharp Not all methods need to be defined. If a method is not defined,
-sharp scrapy acts as if the downloader middleware does not modify the
-sharp passed objects.
def canshu(self):-sharp
    aa=["192.168.1.2","11.22.33","44,55,66"]
    return aa
b=canshu(1)
-sharpprint("",b)
def order(self):-sharpSs
    print("order",self.canshu())
    for i in range(10):
        yield i
a=order(1)
@classmethod
def from_crawler(cls, crawler):
    -sharp This method is used by Scrapy to create your spiders.
    s = cls()
    crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
    return s
    ......
 scrapy,
 bug
Jun.11,2021

your canshu () and order () are instance methods. If you call them as ordinary functions, you should take an instance object as the first parameter.
you call self.canshu () on its first parameter self in the definition of the order function, and then when you call: a = order (1) , then self is 1 , which is an instance of int, obviously without the .canshu attribute.


def canshu(cls):-sharp
    aa=["192.168.1.2","11.22.33","44,55,66"]
    return aa
b=canshu(1)
-sharpprint("",b)
def order(cls):-sharpSs
    print("order",cls.canshu())
    for i in range(10):
        yield i
    
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b411e4-2c562.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b411e4-2c562.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?