Reputation: 82
I'm making a sqlite3 db and in that, I have a static method that shows all the tables present in the sqlite3 file, but for that file to access the cursor object it needs the self.conn.cur, and if make the cur a global var all the other methods have to be changed so can I use the self arg in the static method? Pls Help. Thanks in advance.
Upvotes: 0
Views: 335
Reputation: 52832
No, a static method will not get any reference to self
- self
is the object the method is being invoked on, and in a static method, there is no object. If the method isn't static - i.e. it requires an object with a connection set, don't define it as static and call it on an object instead.
Another option is to call the static method and provide the connection as an argument. That allows the calling code to determine which connection should be used to retrieve information when called.
Upvotes: 1